首页 > 解决方案 > 在 anaconda 环境中使用 pyinstaller 来打包程序并发出警告:找不到 lib

问题描述

我在anaconda2、python 3.7.3 windows10环境中使用pyinstaller 3.5,并尝试打包我为作业编写的程序。起初我使用 cmd 执行 pyinstaller 并引发了警告

16949 WARNING: lib not found: impi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_intelmpi_ilp64.dll
17067 WARNING: lib not found: impi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_intelmpi_lp64.dll
17169 WARNING: lib not found: pgf90.dll dependency of d:\download\anaconda\Library\bin\mkl_pgi_thread.dll
17225 WARNING: lib not found: pgc14.dll dependency of d:\download\anaconda\Library\bin\mkl_pgi_thread.dll
17280 WARNING: lib not found: pgf90rtl.dll dependency of d:\download\anaconda\Library\bin\mkl_pgi_thread.dll
17340 WARNING: lib not found: mpich2mpi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_mpich2_ilp64.dll
17438 WARNING: lib not found: mpich2mpi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_mpich2_lp64.dll
17571 WARNING: lib not found: msmpi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_msmpi_ilp64.dll
17702 WARNING: lib not found: msmpi.dll dependency of d:\download\anaconda\Library\bin\mkl_blacs_msmpi_lp64.dll

我在网上搜索,发现可能是环境路径问题,但发现我已经添加了anaconda bin路径。然后我使用 anaconda 提示符执行 pyinstaller 命令,它仍然发出警告。我也试过

pyinstaller -D filepath -p anaconda_lib_path

要指定这些 dll 文件所在的路径,但它仍然不起作用,我还编辑了 .spec 文件并将警告中提到的文件添加到 dist 文件夹中,但它也不起作用我只是尝试了我室友的 .exe 文件电脑,它显示:

AttributeError: 'NoneType' object has no attribute 'shape'

应该是 numpy 数组

下午我用另一个室友的电脑执行pyinstaller命令,从来没有安装过anaconda环境。这次没有更多关于 anaconda 文件夹中库的警告。所以我倾向于在前室友的电脑上试一试,以测试没有python和numpy环境是否可以。但是错误:

AttributeError: 'NoneType' object has no attribute 'shape'

又出现了。我还在脚本中添加了一个打印命令,它还显示“无”我还检查了“构建”文件夹下的警告 txt,并显示了许多错误:

missing module named 'multiprocessing.forking' - imported by c:\users\lenovo\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named 'win32com.gen_py' - imported by win32com (conditional, optional), c:\users\lenovo\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_win32comgenpy.py (top-level)
missing module named pyimod03_importers - imported by PyInstaller.loader.pyimod02_archive (delayed, conditional), c:\users\lenovo\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level)
missing module named StringIO - imported by six (conditional), PyInstaller.lib.modulegraph._compat (conditional), PyInstaller.lib.modulegraph.zipio (conditional), setuptools._vendor.six (conditional), numpy.lib.utils (delayed, conditional), numpy.lib.format (delayed, conditional), numpy.testing._private.utils (conditional), pkg_resources._vendor.six (conditional)
missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.requirements (top-level), pkg_resources._vendor.packaging.markers (top-level)
missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional)
missing module named com - imported by pkg_resources._vendor.appdirs (delayed)
missing module named _uuid - imported by uuid (optional)
missing module named __builtin__ - imported by numpy.core.numerictypes (conditional), numpy.core.numeric (conditional), numpy.lib.function_base (conditional), numpy.lib._iotools (conditional), numpy.ma.core (conditional), numpy.distutils.misc_util (delayed, conditional), numpy (conditional), pkg_resources._vendor.pyparsing (conditional), setuptools._vendor.pyparsing (conditional)
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional), setuptools._vendor.pyparsing (optional)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named 'macholib.MachO' - imported by PyInstaller.depend.dylib (delayed), PyInstaller.depend.bindepend (delayed), PyInstaller.utils.osx (top-level)
missing module named macholib - imported by PyInstaller.depend.dylib (delayed, conditional)
missing module named _pkgutil - imported by PyInstaller.lib.modulegraph.modulegraph (delayed, optional)
missing module named dis3 - imported by PyInstaller.lib.modulegraph._compat (conditional)
missing module named urllib.pathname2url - imported by urllib (conditional), PyInstaller.lib.modulegraph._compat (conditional)
missing module named pyimod00_crypto_key - imported by PyInstaller.loader.pyimod02_archive (delayed, optional)
missing module named thread - imported by numpy.core.arrayprint (conditional, optional), PyInstaller.loader.pyimod02_archive (conditional)
missing module named 'macholib.dyld' - imported by PyInstaller.depend.bindepend (delayed)
missing module named 'macholib.mach_o' - imported by PyInstaller.depend.bindepend (delayed)
missing module named Crypto - imported by PyInstaller.building.makespec (delayed, conditional, optional)
missing module named win32ctypes.core._time - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level)
missing module named win32ctypes.core._system_information - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level)
missing module named win32ctypes.core._resource - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level)
missing module named win32ctypes.core._dll - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level)
missing module named win32ctypes.core._common - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32api (top-level), win32ctypes.pywin32.win32cred (top-level)
missing module named win32ctypes.core._authentication - imported by win32ctypes.core (top-level), win32ctypes.pywin32.win32cred (top-level)
missing module named cffi - imported by win32ctypes.core (optional)
missing module named UserDict - imported by PyInstaller.compat (conditional)
missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources (top-level), pkg_resources._vendor.packaging.requirements (top-level)
missing module named pkg_resources.extern.six - imported by pkg_resources.extern (top-level), pkg_resources (top-level), pkg_resources.py31compat (top-level)
missing module named resource - imported by posix (top-level), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named posix - imported by os (conditional, optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional), setuptools.sandbox (conditional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), PyInstaller.loader.pyimod02_archive (delayed, conditional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named _winreg - imported by platform (delayed, optional), numpy.distutils.cpuinfo (delayed, conditional, optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level), pkg_resources._vendor.appdirs (delayed, conditional)
missing module named java - imported by platform (delayed), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named vms_lib - imported by platform (delayed, conditional, optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named termios - imported by tty (top-level), getpass (optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed), distutils.archive_util (optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), pathlib (delayed, conditional, optional), distutils.util (delayed, conditional), distutils.archive_util (optional), netrc (delayed, conditional), getpass (delayed), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named org - imported by copy (optional), D:\PS_effect_demo\PS_effect_demo_ver1.2.1.py (top-level)
missing module named commands - imported by numpy.distutils.cpuinfo (conditional)
missing module named setuptools.extern.packaging - imported by setuptools.extern (top-level), setuptools.dist (top-level), setuptools.command.egg_info (top-level)
missing module named 'setuptools.extern.six' - imported by setuptools (top-level), setuptools.extension (top-level)
missing module named 'setuptools.extern.packaging.version' - imported by setuptools.config (top-level), setuptools.msvc (top-level)
missing module named setuptools.extern.six.moves.filterfalse - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.msvc (top-level)
missing module named setuptools.extern.six.moves.filter - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.ssl_support (top-level), setuptools.command.py36compat (top-level)
missing module named _manylinux - imported by setuptools.pep425tags (delayed, optional)
missing module named 'setuptools.extern.packaging.utils' - imported by setuptools.wheel (top-level)
missing module named wincertstore - imported by setuptools.ssl_support (delayed, optional)
missing module named 'backports.ssl_match_hostname' - imported by setuptools.ssl_support (optional)
missing module named backports - imported by setuptools.ssl_support (optional)
missing module named 'setuptools._vendor.six.moves' - imported by 'setuptools._vendor.six.moves' (top-level)
missing module named 'setuptools.extern.pyparsing' - imported by setuptools._vendor.packaging.markers (top-level), setuptools._vendor.packaging.requirements (top-level)
missing module named setuptools.extern.six.moves.map - imported by setuptools.extern.six.moves (top-level), setuptools.dist (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.namespaces (top-level)
runtime module named setuptools.extern.six.moves - imported by setuptools.dist (top-level), setuptools.py33compat (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.command.setopt (top-level), setuptools.package_index (top-level), setuptools.ssl_support (top-level), setuptools.command.egg_info (top-level), setuptools.command.py36compat (top-level), setuptools.namespaces (top-level), setuptools.msvc (top-level), 'setuptools._vendor.six.moves' (top-level)
missing module named setuptools.extern.six - imported by setuptools.extern (top-level), setuptools.monkey (top-level), setuptools.dist (top-level), setuptools.extern.six.moves (top-level), setuptools.py33compat (top-level), setuptools.config (top-level), setuptools.command.easy_install (top-level), setuptools.sandbox (top-level), setuptools.py27compat (top-level), setuptools.package_index (top-level), setuptools.wheel (top-level), setuptools.pep425tags (top-level), setuptools.command.egg_info (top-level), setuptools.command.sdist (top-level), setuptools.command.bdist_egg (top-level), setuptools.unicode_utils (top-level), setuptools.command.develop (top-level)
missing module named 'numpy_distutils.cpuinfo' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named 'numpy_distutils.fcompiler' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named 'numpy_distutils.command' - imported by numpy.f2py.diagnose (delayed, conditional, optional)
missing module named numpy_distutils - imported by numpy.f2py.diagnose (delayed, optional)
missing module named __svn_version__ - imported by numpy.f2py.__version__ (optional)
missing module named numarray - imported by numpy.distutils.system_info (delayed, conditional, optional)
missing module named Numeric - imported by numpy.distutils.system_info (delayed, conditional, optional)
missing module named ConfigParser - imported by numpy.distutils.system_info (conditional), numpy.distutils.npy_pkg_config (conditional)
missing module named _curses - imported by curses (top-level), curses.has_key (top-level)
missing module named _dummy_threading - imported by dummy_threading (optional)
missing module named pytest - imported by numpy._pytesttester (delayed)
missing module named 'nose.plugins' - imported by numpy.testing._private.noseclasses (top-level), numpy.testing._private.nosetester (delayed)
missing module named scipy - imported by numpy.testing._private.nosetester (delayed, conditional)
missing module named 'nose.util' - imported by numpy.testing._private.noseclasses (top-level)
missing module named nose - imported by numpy.testing._private.utils (delayed, optional), numpy.testing._private.decorators (delayed), numpy.testing._private.noseclasses (top-level)
missing module named dummy_thread - imported by numpy.core.arrayprint (conditional, optional)
missing module named cPickle - imported by numpy.core.numeric (conditional)
missing module named cStringIO - imported by cPickle (top-level)
missing module named copy_reg - imported by cPickle (top-level), cStringIO (top-level), numpy.core (conditional)
missing module named pickle5 - imported by numpy.core.numeric (conditional, optional)
missing module named numpy.core.number - imported by numpy.core (delayed), numpy.testing._private.utils (delayed)
missing module named numpy.core.signbit - imported by numpy.core (delayed), numpy.testing._private.utils (delayed)
missing module named numpy.core.float64 - imported by numpy.core (delayed), numpy.testing._private.utils (delayed)
missing module named numpy.core.float32 - imported by numpy.core (top-level), numpy.testing._private.utils (top-level)
missing module named numpy.lib.i0 - imported by numpy.lib (top-level), numpy.dual (top-level)
missing module named numpy.core.integer - imported by numpy.core (top-level), numpy.fft.helper (top-level)
missing module named numpy.core.sqrt - imported by numpy.core (top-level), numpy.linalg.linalg (top-level), numpy.fft.fftpack (top-level)
missing module named numpy.core.conjugate - imported by numpy.core (top-level), numpy.fft.fftpack (top-level)
missing module named numpy.core.divide - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.object_ - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.intp - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.geterrobj - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.add - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.complexfloating - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.inexact - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.cdouble - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.csingle - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.double - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named numpy.core.single - imported by numpy.core (top-level), numpy.linalg.linalg (top-level)
missing module named future_builtins - imported by numpy.lib.npyio (conditional)
missing module named urllib2 - imported by numpy.lib._datasource (delayed, conditional)
missing module named urlparse - imported by numpy.lib._datasource (delayed, conditional)
missing module named numpy.recarray - imported by numpy (top-level), numpy.ma.mrecords (top-level)
missing module named numpy.dtype - imported by numpy (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level)
missing module named numpy.expand_dims - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.array - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level)
missing module named numpy.bool_ - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.mrecords (top-level)
missing module named numpy.iscomplexobj - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.amin - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.amax - imported by numpy (top-level), numpy.ma.core (top-level)
missing module named numpy.ndarray - imported by numpy (top-level), numpy.ma.core (top-level), numpy.ma.extras (top-level), numpy.ma.mrecords (top-level), numpy.ctypeslib (top-level)
missing module named numpy.histogramdd - imported by numpy (delayed), numpy.lib.twodim_base (delayed)
missing module named numpy.eye - imported by numpy (delayed), numpy.core.numeric (delayed)
missing module named Carbon - imported by wx.lib.colourutils (conditional, optional)

我发现 numpy 在“丢失”的库中,我怎么想知道如何将 numpy 库添加到可执行文件夹中,这样我就可以在没有 numpy、cv2、wxpython 和 python 环境的计算机中执行 .exe 文件?

标签: pythonanacondapyinstaller

解决方案


这可能是程序的错误,而不是 pyinstaller 的问题,也许你的变量有机会成为None,所以你应该尝试检查程序以确保运行函数 ( shape) 的变量总是而不是None


推荐阅读