I have Ubuntu 12.04 with Python 2.7 and 3.2
Following this page I installed requests module.

$ sudo pip install requests

However, it only works for Python 2 but not Python 3:

$ python
Python 3.2.3 (default, Apr 10 2013, 06:11:55) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named requests

How should I install the requests module so it can work for both my Python versions?


Answered by OP:

I figured it out by following various answers from here. The answer is I have to have pip-3.2 installed first. I am not sure all steps are necessary though:

$ sudo apt-get install python3-pip
$ sudo apt-get install python3-setuptools
$ sudo python3 -m easy_install pip
Installing pip script to /usr/local/bin
Installing pip-3.2 script to /usr/local/bin
.. Now I get pip-3.2:

$ sudo pip-3.2 install requests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.