我有一个完整的项目文件夹,每当我试图运行一个文件时,Pycharm都会在其中返回错误。如果我从航站楼查出来的话,它们都能工作。在
/usr/bin/python /Users/Casper/PycharmProjects/Mayer/Mayer5.py Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 550, in main() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 532, in main known_paths = addusersitepackages(known_paths) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 266, in addusersitepackages user_site = getusersitepackages() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 241, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 230, in getuserbase from sysconfig import get_config_var File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 104, in _PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 99, in _safe_realpath return realpath(path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 375, in realpath path, ok = _joinrealpath('', filename, {}) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 400, in _joinrealpath if not islink(newpath): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 138, in islink return stat.S_ISLNK(st.st_mode) AttributeError: 'module' object has no attribute 'S_ISLNK'
从this post来看,可能有两个原因:
循环依赖:
如果在第一个},那么你可能会看到这种情况。Python将自己决定首先加载哪个模块。
a.py
文件中import b
,而在b.py
中你{在您的
.py
中命名的模块与Python标准文件中命名的模块相同:在这种情况下,您必须更改模块名称。
你需要提供更多关于你的代码的信息,这样我们才能找出哪一个是根本原因。在
相关问题 更多 >
编程相关推荐