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

你说的曾经没有我的故事 提交于 2020-02-03 08:35:11

问题


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'

回答1:


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




回答2:


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.




回答3:


I have checked your code, and there is no any ERROR but i see this message: PermissionError: [Errno 1] Operation not permitted: '/home/beenj/Documents' means we must run python3 with sudo ==> sudo python3 then enter above code... or run compiled Python application (after completing ) in SuperUserDO (sudo)



来源:https://stackoverflow.com/questions/40051790/attributeerror-module-os-has-no-attribute-chroot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!