我已经使用PyQt5和pyqtgraph编写了一个应用程序,它使用qt_backport为PyQt5提供pyqtgraph支持,因为pyqtgraph目前不支持PyQt5。我正在尝试使用cx_Freeze为此应用程序创建可执行文件,但遇到以下错误:
当我尝试打开应用程序时会发生这种情况。当建筑物实际发生时,cx_Freeze不会抛出任何错误。 qt_backport包含在cx_Freeze构建应用程序时生成的库zip文件夹中。这是运行
输出的pastebinpython setup.py build
当我将它作为python脚本运行时,应用程序运行正常,所以我不确定这里发生了什么。我的setup.py文件如下所示:
# -*- coding: utf-8 -*-
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
options = {
'build_exe': {
'includes': ['atexit', 'qt_backport'],
'packages': 'qt_backport'
}
}
executables = [
Executable('DataViewer.py', base=base)
]
setup(name='DataViewer',
version='0.1',
description='Application for viewing Prairie-generated csv data files',
options=options,
executables=executables
)
我应该注意到我已经使用cx_Freeze测试了一个简单的PyQt5应用程序,一切正常,所以问题是针对这里发生的事情(而不是我的python / cx_Freeze安装的更大问题)
编辑: 使用py2exe会产生相同类型的错误:
Traceback (most recent call last):
File "DataViewer.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Anaconda3\envs\pyqt5\lib\site-packages\pyqtgraph\__init__.py", line 15, in <module>
from .Qt import QtGui
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Anaconda3\envs\pyqt5\lib\site-packages\pyqtgraph\Qt.py", line 71, in <module>
raise Exception(msg)
Exception: PyQtGraph requires one of ('PySide', 'PyQt4'), but none of these could be imported. PyQt5 was detected, but to use it you you must also install qt_backport.
再一次,qt_backport文件夹以及应该在该文件夹中的文件都在库zip文件中。