“KeyError:'PYTHONPATH'”。在python3中破坏了Sites.py?

时间:2018-04-23 23:42:37

标签: python python-3.x site-packages

我认为当我做一些brew更新的东西时,这已经变成了foobarred。每次调用我的系统python3时,它都会发出:

Error in sitecustomize; set PYTHONVERBOSE for traceback:  
KeyError: 'PYTHONPATH'

这特别令人烦恼,因为我在终端中使用powerline,而powerline每次执行命令时都会调用python。

用我得到的详细标志调用Python3:

$ PYTHONVERBOSE=True python3

<multiple pages of python startup info...>

# possible namespace for /usr/local/lib/python2.7/site-packages/backports
# bytecode is stale for 'sitecustomize'
# code object from /usr/local/lib/python2.7/site-packages/sitecustomize.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 481, in execsitecustomize
    import sitecustomize
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/usr/local/lib/python2.7/site-packages/sitecustomize.py", line 15, in <module>
    str(sys.version_info[0]) + '.x!\n     PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\n' +
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'PYTHONPATH'
# destroy sitecustomize
import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x101e3a630>

<more python startup info...>

因此系统Python3正在尝试加载sitecustomize的Python2版本?我怀疑那是问题所在。如果是这样,我可以选择解决这个问题? brew unlink python3 && brew link python3没有帮助。

我不确定bytecode is stale for 'sitecustomize'评论python的用途是什么,但我也删除了sitecustomize.pyc文件,但没有帮助。

0 个答案:

没有答案