如何在 Python 3.4 而不是 2.7 中安装请求模块 [英] How to install requests module in Python 3.4, instead of 2.7

查看:25
本文介绍了如何在 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升级):requests in/usr/lib/python2.7/dist-packages"

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

即使 3.4 已经在 2.7 中,我如何指导 pip 安装它?

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

这篇关于如何在 Python 3.4 而不是 2.7 中安装请求模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆