简体   繁体   English

使用第三方库进行Python部署

[英]Python deployment with third-party libraries

I want to deploy an executable (.exe) from my python2.7 project with everything included. 我想从python2.7项目中部署包含所有内容的可执行文件(.exe)。 I have seen pyinstaller and py2exe but the problem is that my project uses a lot of third-party packages that are not supported by default. 我见过pyinstaller和py2exe,但是问题是我的项目使用了很多默认情况下不支持的第三方软件包。 What is the best choice for such cases? 此类情况的最佳选择是什么? Is there any other distribution packager that could be used? 还有其他可以使用的分发打包程序吗?

Thank you 谢谢

The executable creation packages should be able to grab 3rd party packages if they're installed. 如果安装了可执行文件创建软件包,它们应该能够获取第三方软件包。 Sometimes you have to specify what to include if the library abuses Python's importing system or it's not a "pure Python" package. 有时,如果库滥用Python的导入系统或者它不是“纯Python”包,则必须指定要包括的内容。 For example, I would sometimes have to specifically include lxml to get py2exe to pick it up properly. 例如,有时我必须专门包含lxml来使py2exe正确地将其拾取。

The py2exe project for Python 2 hasn't been updated in quite a long time, so I would certainly recommend one of the alternatives: PyInstaller, cx_freeze or bb_freeze. Python 2的py2exe项目已经很长时间没有更新了,因此我当然会推荐以下替代方法之一:PyInstaller,cx_freeze或bb_freeze。

I have only seen issues with MSVCP90.dll when using non pure Python packages, such as wxPython. 使用非纯Python包(例如wxPython)时,我仅看到MSVCP90.dll问题。 Normally you can add that in your setup.py to include it. 通常,您可以在setup.py中添加它以包括它。 If that doesn't work, then you could also add it using an installer utility like NSIS. 如果那不起作用,那么您也可以使用NSIS之类的安装程序实用程序来添加它。 Or you may just have to state in your README that your app depends on Microsoft's C++ redistributable and include a link to it. 或者,您可能只需要在自述文件中声明您的应用程序依赖于Microsoft的C ++可再发行组件,并包含一个指向它的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM