How to install requests module in Python 3.4, instead of 2.7

Thom Rogers picture Thom Rogers · May 21, 2015 · Viewed 253.5k times · Source

I have both Python 2.7 and 3.4 installed on my Ubuntu 14.04 machine. I want to install the 'requests' module so it is accessible from Py3.4.

When I issued pip install requests on my terminal cmd line I got back:

"Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages"

How can I direct pip to install requests for 3.4 even though it is already in 2.7?

Answer

b4hand picture b4hand · May 21, 2015

You can specify a Python version for pip to use:

pip3.4 install requests

Python 3.4 has pip support built-in, so you can also use:

python3.4 -m pip install

If you're running Ubuntu (or probably Debian as well), you'll need to install the system pip3 separately:

sudo apt-get install python3-pip

This will install the pip3 executable, so you can use it, as well as the earlier mentioned python3.4 -m pip:

pip3 install requests