“ImportError: No module named httplib2” even after installation

不羁岁月 提交于 2019-11-27 13:04:07
kenorb

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).

added this to .bash_profile export PATH=/usr/local/bin:$PATH

then got:

$ 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
>>> 

can't say for sure why pip was installing to /usr/local instead of system default, but now they're the same, so it's working for now.

I faced similar problems on Windows 7. Here is how I solved it:

  1. Install Python: Simply download Python and follow the installation instructions of the wizard.
  2. Now, Python should be accessible from the command line. However, in my case, calling

    py script.py resulted in the the same error: "ImportError: No module named httplib2"

  3. I then had to add the Python and Pip installation paths to the "Path" environment variable in order to install the httplib2 module and then execute the script without failure. I followed the instructions provided here.

  4. Then I was able to execute

    pip3 install httplib2 --upgrade

  5. In the end I successfully managed to execute the script containing the httplib2 import statement.

On Ubuntu:

Installing the library using the Ubuntu package manager fixed my issue:

sudo apt-get install python-httplib2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!