安装Anaconda后,我得到常量"KeyError:'PYTHONPATH'",讯息 [英] After installing Anaconda, I get constant "KeyError: 'PYTHONPATH'" messages

查看:491
本文介绍了安装Anaconda后,我得到常量"KeyError:'PYTHONPATH'",讯息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac上安装适用于Python 3.4的Anaconda之后,我不断收到以下消息:

After installing Anaconda for Python 3.4 on my Mac I get constant messages saying:

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

根据用户在另一个问题上的建议,我使用了

As suggested by a user on another question, I used

PYTHONVERBOSE=1 conda update --all

并收到了回溯:

Traceback (most recent call last):
  File "/Users/user/anaconda/lib/python3.4/site.py", line 506, in execsitecustomize
    import sitecustomize
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, 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 "/Users/user/anaconda/lib/python3.4/os.py", line 633, in __getitem__
    raise KeyError(key) from None
KeyError: 'PYTHONPATH'
# destroy sitecustomize

我环顾四周,发现os.environ中不存在"PYTHONPATH"作为键.

I have looked around and found that 'PYTHONPATH' does not exist as a key in os.environ.

推荐答案

如果设置了PYTHONPATH环境变量,请取消设置它.您可以使用echo $PYTHONPATH进行检查.如果已设置,则可能来自〜/.profile或〜/.bash_profile中的内容.

If your PYTHONPATH environment variable is set, unset it. You can check with echo $PYTHONPATH. If it is set it is probably coming from something in ~/.profile or ~/.bash_profile.

问题是文件/usr/local/lib/python2.7/site-packages/sitecustomize.py.您可能要检查该文件是什么以及它来自何处,但是将其删除应该可以解决此问题.

The issue is the file /usr/local/lib/python2.7/site-packages/sitecustomize.py. You may want to check what that file is and where it comes from, but removing it should fix the problem.

这篇关于安装Anaconda后,我得到常量"KeyError:'PYTHONPATH'",讯息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆