使用pyinstaller warnout缺少模块将python3.5代码转换为exe文件

时间:2016-12-13 14:50:46

标签: windows python-3.x pyinstaller

我正在使用pyinstaller将我的python 3.5程序转换为exe文件,这是我的环境: 系统:windows 10 python:python 3.5,我正好安装了Anaconda3-4.2.0-Windows-x86_64.exe pyinstaller:3.2 我已经在pyinstall文件中复制了myfile.py

然后我在cmd中运行:

cd C:\Program Files\Anaconda3\Scripts
pyinstaller.exe -F myfile.py

代码运行成功,我有2个文件夹

C:\Program Files\Anaconda3\Scripts\build
C:\Program Files\Anaconda3\Scripts\dist

在“C:\ Program Files \ Anaconda3 \ Scripts \ dist”中,我收到了一个myfile.exe,当我运行它时出错,发生了错误:

Traceback (most recent call last):
   File "site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line  11, in <module>
   File "c:\program files\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
   exec(bytecode, module.__dict__)
   File "site-packages\setuptools-27.2.0-py3.5.egg\pkg_resources\__init__.py", line 68, in <module>
   File "site-packages\setuptools-27.2.0-py3.5.egg\pkg_resources\extern\__init__.py", line 61, in load_module
ImportError: The 'appdirs' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
Failed to execute script pyi_rth_pkgres

我检查了C:\ Program Files \ Anaconda3 \ Scripts \ build \ myfile \ warnout.txt中的日志,然后收到警告:

missing module named PyQt5.QtCore.QCoreApplication - imported by PyQt5.QtCore, c:\program files\anaconda3\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py
missing module named PyQt5.QtCore.QIODevice - imported by PyQt5.QtCore
missing module named PyQt5.QtCore.QBuffer - imported by PyQt5.QtCore
missing module named PyQt5.QtGui.QPixmap - imported by PyQt5.QtGui
missing module named PyQt5.QtGui.QImage - imported by PyQt5.QtGui
missing module named PyQt5.QtGui.qRgba - imported by PyQt5.QtGui
missing module named 'PyQt5.sip' - imported by c:\program files\anaconda3\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py
missing module named numpy.infty - imported by numpy, scipy.sparse.linalg.isolve.lsmr
missing module named numpy.finfo - imported by numpy, scipy.sparse.linalg.isolve.minres, scipy.optimize.slsqp, scipy.optimize.minpack, scipy.optimize.zeros
missing module named numpy.inner - imported by numpy, scipy.sparse.linalg.isolve.minres
missing module named pandas.core.base.NoNewAttributesMixin - imported by pandas.core.base, pandas.core.strings, pandas.tseries.common, pandas.core.categorical
missing module named pandas.core.base.PandasDelegate - imported by pandas.core.base, pandas.tseries.common, pandas.core.categorical
missing module named pandas.core.base.AccessorProperty - imported by pandas.core.base, pandas.core.strings

有很多这样的警告,我也尝试过类似的代码:

pyinstaller.exe -F "myfile.py"
pyinstaller.exe --onefile "myfile.py"
pyinstaller.exe -F -p C:\Program Files\Anaconda3\Lib\site-packages\pandas myfile.py   #(-p options like this)

但我也得到了相同的结果(没有发生错误,但发生了警告,并且exe文件无法使用)

我该怎么办?谢谢!

1 个答案:

答案 0 :(得分:0)

我刚解决了,就这样做了:

首先安装pyinstaller

set -o nounset

因为如果使用pyinstaller.exe安装pyinstaller,你可能会缺少一些dependents包。然后

pip install pyinstaller
是的,你就是这样做的。 然后,从

下载pyinstaller开发的版本

https://github.com/pyinstaller/pyinstaller

然后,解压缩zip文件,在文件中运行cmd,

pip unistall pyinstaller

没关系......