获取没有(选定的)电池的 Python
我非常喜欢 Python 的“包含电池”理念,但现在我必须执行精简安装,仅包含核心功能和其他一些我想一一选择的功能。
是否可以仅下载包含选定模块的 Python?
I very like the "battery included" philosophy of Python but now I have to perform a slim installation with only core features and some other which I'd like to choose one by one.
Is it possible to download Python with only selected modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正常安装 python。打开 python 解释器并导入一些你认为不需要的东西。
然后模块的
str
表示形式中就有其路径。您可以直接进入并删除安装中不需要的任何
.py
文件。显然这是危险的,因为你并不真正了解 Python 模块的内部依赖关系。
Install python as normal. Open up the python interpreter and import some of the stuff you think you won't want.
Then the
str
representation of the module has its path in itYou can just go in and remove whatever
.py
files you dont want in your installation.Obviously this is dangerous because you don't really know the internal dependencies of the Python modules.
查看 py2exe 或类似项目。他们基本上将 Python 脚本及其所有依赖项打包在一个可执行文件中。看起来这对你来说是正确的事情。
如果我记得 py2exe 中还有一个独立的模块可以递归地分析 Python 模块的依赖关系,但我现在找不到它了。
Have a look at py2exe or similar projects. They basically package a Python script with all its dependency in a single executable. It looks like it would be the right thing for you.
If I recall there's also an independent module in py2exe that recursively analyses the dependency of a Python module, I can't find it now though.
ActivePython< /a> 不包含测试,并提供安装时选项来排除文档和 PyWin32(虽然不适用于 tcl/tkinter - 但您可以在安装后安全地删除它) )。
或者,您可以使用 PyInstaller 为您的应用创建自定义安装程序。
ActivePython does not include tests, and provides a install-time option to exclude documentation and PyWin32 (though not for tcl/tkinter - but you can safely delete it after install).
Alternatively you could use PyInstaller to create a customized installer for your app.
AFAIK 不可能下载仅包含选定模块的 Python,但安装后您可以删除不需要的所有内容(阅读:库)(永远不会使用 JSON?消失!等) 。
AFAIK it's not possible to download Python with only selected modules, but after an install you can remove everything (read: the libraries) you don't need (never going to use JSON? Gone!, etc).
您可以从 TinyPy 开始,然后添加您需要的内容。然而,TinyPy 似乎没有维护。
You can start from TinyPy, and add what you needed. However, TinyPy seems to be unmaintained though.