3

I am trying to use httplib2 in Python 2.7 on Windows 7 using the IDLE PythonWin 32 build 219.
I downloaded it and installed using python setup.py install method.
On Windows command line the following is successful:

python
import httplib2
httplib2
<module 'httplib2' from 'C:\Python27\ArcGISx6410.2\lib\site-packages\httplib2-0.9.2-py2.7.egg\httplib2\__init__.pyc'>

Here's the problem: in PythonWin importing httplib2 returns:
Traceback (most recent call last): File "<interactive input>", line 1, in <module> ImportError: No module named httplib2

I added the location of the module returned in command line (above) using sys.path.append in command line hoping that would resolve the issue.

PythonWin still cannot import the module, and sys.path in PythonWin does not return the appended path to httplib2. I appended the path the same way in PythonWin, but still could not import the module, and when I reopened PythonWin, the path did not cotain the appended module anymore.

Why or how could PythonWin be using a different path, and how can I get PythonWin to be able to import httplib2?

Evan
  • 1,960
  • 4
  • 26
  • 54
  • PythonWin32 is a module... what do you mean by 'inside PythonWin'? – Corley Brigman May 20 '16 at 20:26
  • I'm using the PythonWin IDLE. Edited my question to clarify. – Evan May 20 '16 at 20:28
  • hmm... well, your python path is nonstandard (the normal directory would be c:\python27\lib\site_packages, but yours has the ArcGIS thing in the middle). I guess you did that when installing? Do you have more than one python installed on the machine? IDLE is probably expecting python to be at c:\python27. – Corley Brigman May 20 '16 at 20:36
  • Maybe the nonstandard path is causing problems. Unfortunately this is my work computer and it was all set up before me, and there are strict admin privileges so I can't change too much. – Evan May 20 '16 at 20:56
  • 1
    Can you check your path, and make sure that `c:\python27\ArcGISx6410.2` is in your path (and not just `c:\python27`, which would be more normal)? Since you can do it from the command line, it has to be some path difference between starting python and starting IDLE. Alternative, if you just need a python distribution, you could try Anaconda, which has its own packager, and can be installed into any directory (if you have one you can access... even Documents would work). – Corley Brigman May 20 '16 at 21:01
  • Seems I just have to run `sys.path.append` before importing the module every time the script runs; probably not ideal but works for now. I will check out Anaconda, thanks for the suggestion. – Evan Jun 01 '16 at 16:58

1 Answers1

1

Have you tried using the command line tool pip ? You can use it like so:

pip install httplib2  

That should put it on your path. If you don't have pip installed see this post. Also, worth mentioning, httplib2 is not as friendly as requests which I personally prefer.

Community
  • 1
  • 1
jfunk
  • 7,176
  • 4
  • 37
  • 38
  • I did try that, and that created another confusing problem for me. Whenever using PIP I get the error `ImportError: No module named commands.install`. Looked on SO and haven't been able to figure that one out either. – Evan May 20 '16 at 20:58
  • I did get this to work eventually using pip, with the addition of the `--trusted-host pypi.python.org` option, from [this question](https://stackoverflow.com/questions/16370583/pip-issue-installing-almost-any-library). – Evan Nov 21 '17 at 16:57