python - cx_freeze - ImportError:无法在 PATH 上找到 Qt5Core.dll
问题描述
我使用 PyQT5、folium、OSMnX 和 geopandas 创建了一个地理空间 GUI 应用程序。该应用程序在此处提到的 OSMnX 专用 Anaconda 环境中运行。
版本信息为:Python - 3.9、Cx_Freeze - 6.8、PyQt - 5.12.3、Qt - 5.12.9、
我想将应用程序转换为可执行文件并为此目的使用 cx_freeze。我成功地完成了构建过程并在构建目录中找到了 .exe 文件。用于构建的 setup.py 如下所示:
"""
A simple setup script to create an executable using PyQt5. This also
demonstrates the method for creating a Windows executable that does not have
an associated console.
PyQt5app.py is a very simple type of PyQt5 application
Run the build process by running the command 'python setup.py build'
If everything works well you should find a subdirectory in the build
subdirectory that contains the files needed to run the application
"""
import sys
from cx_Freeze import setup, Executable
try:
from cx_Freeze.hooks import get_qt_plugins_paths
except ImportError:
include_files = []
else:
# Inclusion of extra plugins (new in cx_Freeze 6.8b2)
# cx_Freeze imports automatically the following plugins depending of the
# use of some modules:
# imageformats - QtGui
# platforms - QtGui
# mediaservice - QtMultimedia
# printsupport - QtPrintSupport
#
# So, "platforms" is used here for demonstration purposes.
include_files = get_qt_plugins_paths("PyQt5", "platforms") + ['input/','output/']
# print(include_files)
# base="Win32GUI" should be used only for Windows GUI app
base = None
if sys.platform == "win32":
base = "Win32GUI"
build_exe_options = {
"excludes": ["tkinter"],
"include_files": include_files,
}
bdist_mac_options = {
"bundle_name": "Test",
}
bdist_dmg_options = {
"volume_label": "TEST",
}
executables = [Executable("main.py", base=base, target_name="CrowdSourcing")]
setup(
name="CrowdSourcing",
version="0.3",
description="CrowsSourcing App",
options={
"build_exe": build_exe_options,
"bdist_mac": bdist_mac_options,
"bdist_dmg": bdist_dmg_options,
},
executables=executables,
)
问题出在执行 .exe 应用程序时,我收到此错误“ImportError: Unable to find Qt5Core.dll on PATH”,如下图所示:
有人可以帮助我解决这个问题,以便我可以运行我的可执行文件吗?
解决方案
推荐阅读
- python - 尽管已安装 Python 无法导入模块
- json - 如何访问从 Flutter 中的 HTTP POST 请求获得的 JSON 响应?
- java - 当您不知道循环中将输入多少个变量时,如何分配多个变量?
- android - 通过 Socket.io websocket 从我的应用程序向特定的 socketId 发送 json 和音频文件
- tensorflow - 验证 GPU 是否在 Keras/Tensorflow 中实际使用,而不仅仅是验证为存在
- c# - 单击按钮时将新文本写入文本框?
- java - 如何让这个 return 语句正常工作?
- c++ - 是否可以创建一个没有数据的节点链表并稍后在 C++ 中填充数据
- r - 通过 R(集群)创建表
- powershell - 使用 ffmpeg 转换目录中的所有文件,然后使用 PowerShell 移动它们