【发布时间】:2019-12-07 19:19:51
【问题描述】:
我安装了一个使用 cx-freeze 冻结的 python/pyqt/matplotlib 应用程序后出现错误。 我使用
构建应用程序python setup.py build
setup.py 是这个
from cx_Freeze import setup, Executable
buildOptions = dict(packages = [], excludes = [])
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('SectionPropertyCalculator.py', base=base)
]
setup(name='Mecanica-SectionPropertyCalculator',
version = '0.1',
description = 'SPC is a GUI to calculate geometrical properties of beam profiles.',
options = dict(build_exe = buildOptions),
executables = executables)
我明白了
Mecanica-SectionPropertyCalculator-0.1-amd64.exe
.exe 在我的开发机器上运行正常
然后我用
创建一个 msi 安装程序cx-freeze app bdist_msi
我明白了
Mecanica-SectionPropertyCalculator-0.1-amd64.msi
我将它安装到另一台具有相同操作系统、i5 处理器等的机器上,但出现错误
File "C:\...SpcPlotQt.py", line 4 in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application
现在,SpcPlotQt.py 是我的代码,在第 4 行我有
from PyQt5.QtWidgets import QDialog, QApplication
我安装了 PyQt5.5.13.2 和 pip3(所有 64 位),我很确定我安装了 python 3.7 x64,我确认了
import struct; print( 8 * struct.calcsize("P"))
64
另外,如果我跑步
import sys; print("%x" % sys.maxsize, sys.maxsize > 2**32)
True
和
import ctypes; print (ctypes.sizeof(ctypes.c_voidp))
8
和
import platform; platform.architecture()[0]
64bit
和
import os; os.environ["PROCESSOR_ARCHITECTURE"]
AMD64
以上所有 5 个测试都表明一切都是 64 位的。
但是当我运行时
import sys; print (sys.platform)
win32
为什么?
AND... cx-freeze 脚本使用 sys.platform 来决定使用什么基础,因此它会选择
base=Win32GUI
我该怎么办?
我注意到python setup.py build 用完了一个 cmd shell,它始终是 32 位,无论我如何打开它;甚至 PowerShell 也是 32 位的。这可能是问题吗?
【问题讨论】:
标签: python numpy matplotlib pyqt cx-freeze