Python 属性错误:模块';操作系统&x27;没有属性';chroot';
下面是我在spyder中运行的非常基本的代码&python令人窒息,我做错了什么Python 属性错误:模块';操作系统&x27;没有属性';chroot';,python,python-3.x,attributeerror,chroot,Python,Python 3.x,Attributeerror,Chroot,下面是我在spyder中运行的非常基本的代码&python令人窒息,我做错了什么 import csv,os,sys path = os.getcwd() print (path) os.chroot(path) 我收到以下错误消息: os.chroot(path) AttributeError: module 'os' has no attribute 'chroot' 一种可能是您的操作系统是Microsoft Windows,我已经检查了您的代码,没有任何错误 但我看到了这个信息
import csv,os,sys
path = os.getcwd()
print (path)
os.chroot(path)
我收到以下错误消息:
os.chroot(path)
AttributeError: module 'os' has no attribute 'chroot'
一种可能是您的操作系统是Microsoft Windows,我已经检查了您的代码,没有任何错误 但我看到了这个信息:
PermissionError:[Errno 1]不允许操作:'/home/beenj/Documents'
意味着我们必须使用sudo
==>sudo python3
然后输入上面的代码。。。
或者在SuperUserDO(sudo)中运行编译好的Python应用程序(完成后)您是否将文件命名为
os.py
?如果您这样做了,它将跟踪stdlib操作系统模块。更改文件名并删除os.pyc
或\uuuuu pycache\uuuu
请在脚本中执行
print os
或类似操作,以查看Python用于获取os
模块的文件路径。是,我使用的是microsoft windows。我很惊讶为什么spyder没有根据我的操作系统向我展示正确的方法,尽管使用了chdir方法来更改目录&问题已经解决了。你在窗户上吗?仅在unix上可用,因此它在windows上不存在。