Problems with PYTHONPATH

孤街浪徒 提交于 2019-12-11 16:31:57

问题


From the command line (Mac OS), when I execute 'echo $PYTHONPATH' I get:

> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

If I then enter the Python interpreter and do the following:

>>> import os
>>> os.environ['PYTHONPATH']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'PYTHONPATH'

Why would this happen?


回答1:


You forgot to export it to the environment so that subprocesses can access it; it's currently only a bash variable.

export PYTHONPATH


来源:https://stackoverflow.com/questions/12664300/problems-with-pythonpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!