使用 pip 为特定的 python 版本安装模块 [英] Install a module using pip for specific python version

查看:38
本文介绍了使用 pip 为特定的 python 版本安装模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Ubuntu 10.04 上,默认安装了 Python 2.6,然后我安装了 Python 2.7.如何使用 pip install 为 Python 2.7 安装软件包.

On Ubuntu 10.04 by default Python 2.6 is installed, then I have installed Python 2.7. How can I use pip install to install packages for Python 2.7.

例如:

pip install beautifulsoup4

默认为 Python 2.6 安装 BeautifulSoup

by default installs BeautifulSoup for Python 2.6

当我这样做时:

import bs4

在 Python 2.6 中它可以工作,但在 Python 2.7 中它说:

in Python 2.6 it works, but in Python 2.7 it says:

No module named bs4

推荐答案

使用针对要安装新包的 Python 实例安装的 pip 版本.

Use a version of pip installed against the Python instance you want to install new packages to.

在许多发行版中,可能有单独的 python2.6-pippython2.7-pip 包,使用二进制名称调用,例如 pip-2.6pip-2.7.如果您的发行版中没有为所需目标打包 pip,您可能会寻找 setuptools 或 easyinstall 包,或者使用 virtualenv(它总是在生成的环境中包含 pip).

In many distributions, there may be separate python2.6-pip and python2.7-pip packages, invoked with binary names such as pip-2.6 and pip-2.7. If pip is not packaged in your distribution for the desired target, you might look for a setuptools or easyinstall package, or use virtualenv (which will always include pip in a generated environment).

pip 的网站 包括安装说明,如果您在分布.

pip's website includes installation instructions, if you can't find anything within your distribution.

这篇关于使用 pip 为特定的 python 版本安装模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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