1

So I have a program I'm converting from python 2.7 to python 3.3. Everything works perfectly in 2.7, but in 3.3 I keep getting:

ImportError: No module named 'httplib2'

Now, I have httplib2 installed, and like I said, it works in python 2.7. The 2.7 version of the program and the 3.3 version are in the same directory, so I wouldn't think that would affect it. Anyone know what the issue is here?

The only relevant code snippets are:

import httplib2
from httplib2 import FileCache
6
  • 1
    Do you have it installed on Python3? Commented Feb 19, 2014 at 1:13
  • Maybe this is going to sound stupid, but I installed the library in the terminal and all I did was type 'python install setup.py'. So, how would I install it for python 3 specifically? Commented Feb 19, 2014 at 1:21
  • If you have setuptools in Python3 I would try python3 install setup.py Commented Feb 19, 2014 at 1:26
  • 1
    Why was this question down-voted? The OP deserves an explanation! Commented Feb 19, 2014 at 1:42
  • I think I have setup tools, but that command gives me a syntax error. Commented Feb 19, 2014 at 1:46

2 Answers 2

1

Try going to terminal and running:

sudo apt-get install python3-httplib2

I know you said you already had it installed, but I was getting the same error and the above resolved it.

Edit: Sorry, I see now you're on OSX. Can you translate the above to the proper command for Mac?

Sign up to request clarification or add additional context in comments.

4 Comments

I get the error 'sudo: apt-get: command not found'. I think this is because OSX does not have sudo installed on it.
Yeah, sorry, I forget that OSX's terminal is different. Let me try and find the equivalent.
Actually I think I got it to install somehow, but I now get this error when running the program: Traceback (most recent call last): File "/Users/Kevin/Documents/UROP/googletranslator3.py", line 81, in <module> import httplib2 File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/httplib2/__init__.py", line 897 print "connect: (%s, %s) ************" % (self.host, self.port) ^ SyntaxError: invalid syntax
Hmm...odd. Perhaps related to this issue?
1

As others have mentioned, that means httplib2 is not installed into your Python 3 installation. Someone recommended you try this:

sudo python3 install setup.py

You mentioned that you got an error—for good reason. python3 takes the filename first. The command really should have been

sudo python3 setup.py install

Installing it this way or in another approved way (say, easy_install-3.3 or pip-3.3) is required. The error you got installing it a different way suggests your installation skipped the 2to3 step, without which the package will contain Python 2 code, which Python 3 will occasionally choke on. Try uninstalling it the previous way and installing it this way.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.