在 Ubuntu 10.04 上默认安装 Python 2.6,然后我安装了 Python 2.7。如何使用 pip install
为 Python 2.7 安装软件包。
例如:
pip install beautifulsoup4
默认为 Python 2.6 安装 BeautifulSoup
当我做:
import bs4
在 Python 2.6 中它可以工作,但在 Python 2.7 中它说:
No module named bs4
原文由 torayeff 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用一个版本的
pip
安装在要安装新包的 Python 实例上。In many distributions, there may be separate
python2.6-pip
andpython2.7-pip
packages, invoked with binary names such aspip-2.6
andpip-2.7
.如果您的发行版中没有为所需目标打包 pip,您可能会寻找 setuptools 或 easyinstall 包,或使用 virtualenv(在生成的环境中总是包含 pip)。pip 的网站 包含安装说明,如果您在发行版中找不到任何内容。