2013-12-18 101 views
3

我正在使用全新的Python virtualenv。我剛剛使用pip安裝了,但Python無法看到它。Python無法看到用pip安裝的模塊

(venv)$ sudo pip install httplib2 
Requirement already satisfied (use --upgrade to upgrade): httplib2 in  
/usr/local/lib/python2.7/dist-packages 
Cleaning up... 
(venv)$ python 
Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import httplib2 
Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
ImportError: No module named httplib2 

從我的閱讀,這聽起來像這可能是一個路徑問題,但我不知道爲什麼它正在發生,或如何解決它:(

這是sys.path內容:

>>> pprint(sys.path) 
['', 
'/var/apps/ttex/venv/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', 
'/var/apps/ttex/venv/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg', 
'/var/apps/ttex/venv/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', 
'/var/apps/ttex/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg', 
'/var/apps/ttex/venv/lib/python2.7', 
'/var/apps/ttex/venv/lib/python2.7/plat-linux2', 
'/var/apps/ttex/venv/lib/python2.7/lib-tk', 
'/var/apps/ttex/venv/lib/python2.7/lib-old', 
'/var/apps/ttex/venv/lib/python2.7/lib-dynload', 
'/usr/lib/python2.7', 
'/usr/lib/python2.7/plat-linux2', 
'/usr/lib/python2.7/lib-tk', 
'/var/apps/ttex/venv/local/lib/python2.7/site-packages', 
'/var/apps/ttex/venv/lib/python2.7/site-packages'] 

奇怪的是,雖然,如果我運行Python 2.7,我可以看到包:

(venv)$ python2.7 
>>> import httplib2 
>>> 

爲什麼會發生這種情況,我該怎麼辦?

對不起,如果這是重複的,圍繞這個話題有很多問題,但沒有一個似乎給出了一個簡單明確的答案。

回答