Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

python - "ImportError: No module named httplib2" even after installation

I'm having a hard time understanding why I get ImportError: No module named httplib2 after making sure httplib2 is installed. See below:

$ which -a python
/usr/bin/python
/usr/local/bin/python 

$ pip -V
pip 1.4.1 from /usr/local/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7

$ pip list
google-api-python-client (1.2)
httplib2 (0.8)
pip (1.4.1)
pudb (2013.5.1)
Pygments (1.6)
setuptools (1.3.2)
wsgiref (0.1.2)

$ pip install httplib2
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/local/lib/python2.7/site-packages
Cleaning up...

$ python
Python 2.7.5 (default, Sep 12 2013, 21:33:34) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
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

I've also done

$ find / | grep httplib2
/usr/local/lib/python2.7/site-packages/httplib2
/usr/local/lib/python2.7/site-packages/httplib2/__init__.py
[... edited for brevity]

PLUMBING! >shakes fist at heavens<

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If there are multiple Python instances (2 & 3), try different pip, for example:

Python 2:

pip2 install httplib2 --upgrade

Python 3:

pip3 install httplib2 --upgrade

To check what's installed and where, try:

pip list
pip2 list
pip3 list

Then make sure you're using the right Python instance (as suggested in the other answer).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...