Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'os' has no attribute 'chroot'

Below is my very basic code running in spyder & python is choking, what am I doing wrong?

import csv,os,sys
path = os.getcwd()
print (path)
os.chroot(path)

I get following error message:

  os.chroot(path)

AttributeError: module 'os' has no attribute 'chroot'
like image 330
Ashay Avatar asked Oct 14 '16 20:10

Ashay


2 Answers

One possibility is that your operating system is Microsoft Windows, for which os.chroot() is not available.

like image 120
Zero Piraeus Avatar answered Nov 17 '22 05:11

Zero Piraeus


Did you name your file os.py? If you did, it is shadowing the stdlib os module. Change the name of your file and delete os.pyc or __pycache__.

Do print os or similar inside the script to see the file path Python is using to get the os module.

like image 43
Mike Graham Avatar answered Nov 17 '22 04:11

Mike Graham