Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:模块';操作系统&x27;没有属性';chroot';_Python_Python 3.x_Attributeerror_Chroot - Fatal编程技术网

Python 属性错误:模块';操作系统&x27;没有属性';chroot';

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,我已经检查了您的代码,没有任何错误 但我看到了这个信息

下面是我在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,我已经检查了您的代码,没有任何错误 但我看到了这个信息:
PermissionError:[Errno 1]不允许操作:'/home/beenj/Documents'
意味着我们必须使用
sudo
==>
sudo python3
然后输入上面的代码。。。
或者在SuperUserDOsudo)中运行编译好的Python应用程序(完成后)

您是否将文件命名为
os.py
?如果您这样做了,它将跟踪stdlib操作系统模块。更改文件名并删除
os.pyc
\uuuuu pycache\uuuu


请在脚本中执行
print os
或类似操作,以查看Python用于获取
os
模块的文件路径。

是,我使用的是microsoft windows。我很惊讶为什么spyder没有根据我的操作系统向我展示正确的方法,尽管使用了chdir方法来更改目录&问题已经解决了。你在窗户上吗?仅在unix上可用,因此它在windows上不存在。