2011-02-09 58 views
1

請幫我理解這一點。在這裏你可以看到,我有PYTHONPATH集PYTHONPATH從環境中丟失

[email protected]:~$ echo $PYTHONPATH 
:/home/jean/local/lib/python2.6/site-packages 

(從我.bashrc的),但是,如果我嘗試在我的本地站點包推出的東西會被忽略:

[email protected]:~$ 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向我展示上面,則不能忽略:

[email protected]:~$ export PYTHONPATH=:/home/jean/local/lib/python2.6/site-packages 
[email protected]:~$ gtimelog 
# SUCCESS 

任何線索是怎麼回事?

回答

4

很可能,您只需在您的.bashrc中設置shell變量PYTHONPATH,但不會將此變量導出到環境中。通過echo打印僅顯示shell變量具有打印值。嘗試

env | grep PYTHONPATH 

來查詢PYTHONPATH真的是在環境,並確保你真的export它在你的.bashrc

+0

就是這樣!什麼是新手的錯誤。奇怪的是,骨架bashrc(/usr/share/base-files/dot.bashrc)設置HISTCONTROL,PS1和其他沒有導出。 (Ubuntu 10.10) – 2011-02-11 04:38:48

相關問題