如何在Python 3.4(而不是2.7)中安装请求模块

问题描述:

我在Ubuntu 14.04机器上同时安装了Python 2.7和3.4.我想安装请求"模块,以便可以从Py3.4访问该模块.

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.

当我在终端cmd线路上发布pip install requests时,我回来了:

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

已满足要求(使用--upgrade进行升级):/usr/lib/python2.7/dist-packages中的请求"

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

即使在2.7中,我如何指导pip安装对3.4的请求?

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

您可以指定供pip使用的Python版本:

You can specify a Python version for pip to use:

pip3.4 install requests

Python 3.4内置了 pip支持,因此您也可以使用:>

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

python3.4 -m pip install

如果您正在运行Ubuntu(或者也可能是Debian),则需要单独安装系统pip3:

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

这将安装pip3可执行文件,因此您可以使用它以及前面提到的python3.4 -m 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