我得到:
"import error :No Module named 'PyQt5.QtGui'" during the build.
下面是setup.py
文件和.py
的代码段。
请看看并建议我需要对设置文件或我试图生成exe的代码进行更改。
我使用的是winpython
发行版,因此使用大排除列表。
我已经看过使用pyinstaller,但是www.pyinstaller.org
似乎已关闭。如果有将我的代码转换为exe的更简单方法,请共享。
.py中的代码-
import sys
from PyQt5.QtWidgets import QApplication,QPushButton, QInputDialog,
QLineEdit, QFileDialog,QMainWindow
from PyQt5.QtGui import QIcon
import csv
import pathlib
import os
import pandas as pd
import gc
import numpy as np
import matplotlib
import xlsxwriter
设置文件-
import os.path
import sys
from cx_Freeze import setup, Executable
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
build_exe_options = {"packages": ["os","pandas", "numpy","sys","PyQt5.QtWidgets","PyQt5.QtGui","csv","pathlib","gc","matplotlib","xlsxwriter"], "excludes": ["adodbapi","alabaster","algopy","altair-widgets","altair","astroid","astroml","babel","backports-abc","backports.weakref","baresql","bcolz","beautifulsoup4","bkcharts",
"blaze","bleach","blosc","bloscpack","bokeh","boto3","botocore","bottleneck","bqplot","brewer2mpl","brotli","certifi","cffi","chardet","click","cloudpickle","clrmagic","colorama",
"colorcet","coloredlogs","comtypes","cvxcanon","cvxopt","cvxpy","cx-freeze","cycler","cyordereddict","cython","cytoolz","dask","datashader","datashape","db.py","decorator","dill",
"distributed","docopt","docrepr","docutils","ecos","edward","emcee","entrypoints","enum34","fast-histogram","fastcache","fasteners","fastparquet","feather-format","flask-cors",
"flask","formlayout","fuzzywuzzy","geopy","gitdb2","gitpython","gmpy2","greenlet","guidata","guiqwt","h5py","heapdict","holoviews","html5lib","humanfriendly","husl","idna","imageio",
"imagesize","ipykernel","ipyleaflet","ipympl","ipyparallel","ipython-genutils","ipython-sql","ipython","ipywidgets","isort","itsdangerous","jedi","jinja2","jmespath","joblib",
"jsonschema","julia","jupyter-client","jupyter-console","jupyter-core","jupyter-sphinx","jupyter","jupyterlab-launcher","jupyterlab","keras-vis","keras","lasagne","lazy-object-proxy",
"llvmlite","lmfit","locket","lxml","markdown","markupsafe","mccabe","metakernel","mistune","mizani","mkl-service","monotonic","moviepy","mpl-scatter-density","mpld3","mpldatacursor",
"mpmath","msgpack-python","multipledispatch","multiprocess","mypy","mysql-connector-python","nbconvert-reportlab","nbconvert","nbdime","nbformat","netcdf4","networkx","nltk","notebook",
"numba","numdifftools","numexpr","numpydoc","oct2py","octave-kernel","odo","olefile","palettable","pandas-datareader","pandocfilters","param","partd","patsy","pdfrw","pep8","pexpect",
"pg8000","pickleshare","pillow","pip","pkginfo","plotnine","ply","prettytable","prompt-toolkit","protobuf","psutil","ptpython","ptyprocess","pulp","pweave",
"py","pyarrow","pyaudio","pybars3","pybind11","pycodestyle","pycparser","pyflakes","pyflux","pygame","pygments","pylint","pymc3","pymc","pymeta3","pymongo","pyodbc","pyopengl",
"pypandoc","pyparsing","pyqtgraph","pyreadline","pyserial","pystache","pytest","python-dateutil","python-hdf4","python-levenshtein","python-snappy","pythonnet","pythonqwt","pytz","pywavelets",
"pywin32","pywinpty","pywinusb","pyyaml","pyzmq","qtawesome","qtconsole","qtpy","redis","reportlab","requests-file","requests-ftp","requests-toolbelt","requests","rope",
"rpy2","rx","s3fs","s3transfer","scikit-fuzzy","scikit-image","scikit-learn","scikit-neuralnetwork","scikit-optimize","scilab2py","scipy","scs","seaborn","selenium","setuptools",
"simplegeneric","simplejson","sip","six","smmap2","snakeviz","snowballstemmer","sortedcontainers","sounddevice","sphinx-rtd-theme","sphinx","sphinxcontrib-websupport","spyder-notebook","spyder-reports",
"spyder-terminal","spyder","sqlalchemy","sqlite-bro","sqlparse","statsmodels","supersmoother","sympy","tables","tblib","tensorflow","testpath","theano","thriftpy","toolz","tornado","tqdm","traitlets","traittypes","twine",
"twitter","typed-ast","urllib3","vega","vitables","wcwidth","webencodings","werkzeug","wheel","widgetsnbextension","winpython","wordcloud","wrapt","xarray","xlrd","xlwings","zarr","zict"]}
setup(
name="MyProgram",
version="0.1",
description="MyDescription",
options = {"build_exe": build_exe_options},
executables=[Executable("pyqt5.py",
base = ("Win32GUI" if sys.platform == "win32"
else None))],
)
答案 0 :(得分:0)
错误代码表明错误来自此行
from PyQt5.QtGui import QIcon
确定您的环境中已安装PyQT5.QtGui