安装一堆软件包的任何有效方法
我有一台机器安装了我常用的 python 包。 我想在另一台机器或具有不同 python 版本的同一台机器上安装相同的包。我想知道 pip 或 easy-install 或其他方法是否可以让我批量安装这些软件包。当我使用perl时,它有类似捆绑包的东西,如何在python中做到这一点?
I had one machine with my commonly used python package installed.
and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Pip 为此提供了一些很棒的功能。
它允许您使用 pip freeze > 将环境中的所有要求保存在文件中。 reqs.txt
您可以稍后执行:
pip install -r reqs.txt
,您将获得完全相同的环境。您还可以使用命令
pip bundle MyApp.pybundle -r reqs.txt
将多个库捆绑到.pybundle
文件中,然后使用pip install MyApp 安装它.pybundle
。我想这就是您正在寻找的:)
Pip has some great features for this.
It lets you save all requirements from an environment in a file using
pip freeze > reqs.txt
You can then later do :
pip install -r reqs.txt
and you'll get the same exact environnement.You can also bundle several libraries into a
.pybundle
file with the commandpip bundle MyApp.pybundle -r reqs.txt
, and later install it withpip install MyApp.pybundle
.I guess that's what you're looking for :)
我在一个存储库中保留了一个
requirements.txt
文件,其中包含我所有的基本 Python 要求,并使用 PIP 将它们安装在任何新计算机上。我的每个项目都有自己的
requirements.txt
文件,其中包含与 virtualenv 一起使用的所有依赖项。I keep a
requirements.txt
file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine.Each of my projects also has it's own
requirements.txt
file that contains all of it's dependencies for use w/virtualenv.