首页 > 解决方案 > 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”,如下图所示:

在此处输入图像描述

有人可以帮助我解决这个问题,以便我可以运行我的可执行文件吗?

标签: pythonpyqtcx-freeze

解决方案


推荐阅读