如何使用 Pyinstaller 在冻结 Python 2.7 和 Python 3.4 应用程序之间切换?

How do I switch between freezing Python 2.7 and Python 3.4 apps using Pyinstaller?

我有一个用 python 2.7 编写的脚本 EDS_converter.py。当我 运行 pyinstaller EDS_converter.py .exe 有错误时,如果我尝试 运行 我在 python 3.4.

中的代码,我可以复制这些错误

查看 dist 文件夹,我确实看到了 python34.dllpywintypes34.dll。我经常在 Python 3.4 中使用 Pyinstaller 来冻结不同的应用程序。那么如何轻松地在 3.4 和 2.7 之间切换呢?

我已经搜索了一段时间并阅读了 Pyinstaller 文档。我很惊讶没有一个容易找到的解决方案,如果它是重复的,我会删除这个问题。

问题是您的 PATH 环境变量中有 Python 3 pyinstaller 路径。

假设您使用 windows 的默认安装(根据需要进行修改),您可以在命令行中键入:

C:\Python27\Scripts\pyinstaller.exe EDS_converter.py

或者,您也可以调用 pyinstaller 脚本:

C:\Python27\python.exe C:\Python27\Scripts\pyinstaller-script.py EDS_converter.py

我使用了完整路径,因为您的默认 PYTHONPATH 可能指向您的 Python 3 安装。