在对我的 Windows 电脑进行基准测试后,重新安装所有 Python 库的有效方法是什么?

发布于 2024-10-19 06:06:23 字数 266 浏览 4 评论 0原文

由于一些硬件问题,我的 Windows 笔记本电脑即将被更换。在过去的两年里,我经常安装第三方库,我需要在新机器上重新安装它们。我只需要:

  1. 生成当前安装的第三方 python 库的列表
  2. 在新机器上重新安装它们

我现在的想法是查看 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:

  1. Generate a list of third party python libs current installed
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

想挽留 2024-10-26 06:06:23

看一下 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).

榕城若虚 2024-10-26 06:06:23

您可能想研究一下 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文