2

我认为当我在做一些 brew update 的事情时,这会变得很糟糕。每次调用我的系统 python3 时,它都会发出:

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

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

使用 Verbose 标志调用 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正在尝试加载Python2版本的sitecustomize?我怀疑这就是问题所在。如果是这样,我有什么办法来解决这个问题?brew unlink python3 && brew link python3没有帮助。

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

4

0 回答 0