“ ImportError:没有名为httplib2的模块”即使在安装后
发布于 2021-01-29 18:11:20
我有一个很难理解为什么我得到ImportError: No module named httplib2
确保后httplib2都 被 安装。见下文:
$ 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
我也做过
$ find / | grep httplib2
/usr/local/lib/python2.7/site-packages/httplib2
/usr/local/lib/python2.7/site-packages/httplib2/__init__.py
[... edited for brevity]
水暖!>在天堂摇动拳头<
关注者
0
被浏览
51
1 个回答
-
将此添加到.bash_profile
export PATH=/usr/local/bin:$PATH
然后得到:
$ which -a python /usr/local/bin/python /usr/bin/python /usr/local/bin/python $ python Python 2.7.6 (default, Dec 27 2013, 14:07:24) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import httplib2 >>>
无法肯定地说为什么
pip
安装/usr/local
而不是系统默认版本,但是现在它们相同,因此现在可以正常使用。