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

查看:96
本文介绍了使用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天全站免登陆