Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 294
Thom Rogers Avatar asked May 21 '15 00:05

Thom Rogers


People also ask

Is requests included in Python 3?

The Requests library is available for both Python 2 and Python 3 from the Python Package Index (PyPI), and has the following features: Allows you to send HTTP/1.1 PUT, DELETE, HEAD, GET and OPTIONS requests with ease.


2 Answers

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 
like image 52
b4hand Avatar answered Sep 28 '22 18:09

b4hand


On Windows with Python v3.6.5

py -m pip install requests 
like image 41
Code4 Avatar answered Sep 28 '22 17:09

Code4