在对我的 Windows 电脑进行基准测试后,重新安装所有 Python 库的有效方法是什么?
由于一些硬件问题,我的 Windows 笔记本电脑即将被更换。在过去的两年里,我经常安装第三方库,我需要在新机器上重新安装它们。我只需要:
- 生成当前安装的第三方 python 库的列表
- 在新机器上重新安装它们
我现在的想法是查看 c:\python\lib\site-packages 并手动写出列表,然后尝试创建Setuptools 和 EasyInstall 的配置文件,我可以将其作为某种脚本运行,它将安装所有这些库。这可行吗?
My windows laptop is being replaced due to some hardware problems. I've spent the last two years installing third party libraries every so often, which I'll need to reinstall on the new machine. I just need to:
- Generate a list of third party python libs current installed
- Reinstall those on the new machine
My thought right now is to look at c:\python\lib\site-packages and manually write out the list, then try to create a configuration file for Setuptools and EasyInstall which I could run as a script of sorts, which would install all these libraries. Is that feasible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 pip 的 freeze 命令并从需求文件安装:
http://pip.openplans.org/#freezing-requirements
警告:pip 可能不能够在 Windows 中安装所有软件包(我认为对于某些具有必须重新编译的本机库的软件包有一些限制)。
Take a look at pip's freeze command and install from requirements file:
http://pip.openplans.org/#freezing-requirements
Warning: pip may not be able to install all your packages in Windows (I think it has some limitations for some packages with native libraries that must be recompiled).
您可能想研究一下 virtualenv。它让您拥有一个 Python 的“虚拟环境”,从而在未来消除这种需求。至于在新系统上获取旧库,您可以从解释器检查 PYTHONPATH 环境变量和/或 sys.path 以查看搜索到的所有路径,并且您可以环顾四周以查看需要安装的内容回到原来的地方。
You might want to look into virtualenv. It lets you have a "virtual environment" for Python that would eliminate this need in the future. As for getting the old libs on the new system, you can check the PYTHONPATH environment variable and/or sys.path from the interpreter to see what all paths are searched and you can do some looking around to see what you'd need to install to get back to where you were.