请帮我理解这一点。在这里你可以看到我已经设置了PYTHONPATH(它来自我的.bashrc
)
jean@klippie:~$ echo $PYTHONPATH
:/home/jean/local/lib/python2.6/site-packages
但是,如果我尝试在我的本地站点包中启动某些内容,则会被忽略:
jean@klippie:~$ gtimelog
Traceback (most recent call last):
File "/home/jean/bin/gtimelog", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2671, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 654, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: gtimelog==0.5.0
现在,如果我手动将PYTHONPATH导出到上面显示的值echo
,则不会忽略它:
jean@klippie:~$ export PYTHONPATH=:/home/jean/local/lib/python2.6/site-packages
jean@klippie:~$ gtimelog
# SUCCESS
有什么问题?
答案 0 :(得分:4)
最有可能的是,您只在PYTHONPATH
中设置了shell变量.bashrc
,但是您没有将此变量导出到环境中。通过echo
打印仅显示shell变量具有打印值。尝试
env | grep PYTHONPATH
查询PYTHONPATH是否真的在环境中,并确保你export
中确实.bashrc
。