使用PyInstaller创建.exe文件期间的ImportError

时间:2019-05-21 08:41:34

标签: python pyinstaller

我正在尝试从python脚本创建一个.exe文件,以使未安装Python的同事能够在本地运行该文件。该文件在浏览器窗口中运行绘图/破折号可视化。我正在用PyInstaller尝试;以下是我收到的导入错误语句:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
    from . import cbook, rcsetup
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
    import numpy as np
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
739146 INFO: Loading module hook "hook-matplotlib.py"...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
    from . import cbook, rcsetup
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
    import numpy as np
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
739647 INFO: Loading module hook "hook-numpy.core.py"...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
Traceback (most recent call last):
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\pkgutil.py", line 493, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 320, in get_module_file_attribute
    loader = pkgutil.find_loader(package)
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\pkgutil.py", line 499, in find_loader
    raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for 'numpy.core' (<class 'ImportError'>: DLL load failed: Das angegebene Modul wurde nicht gefunden.)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\Scripts\pyinstaller-script.py", line 10, in <module>
    sys.exit(run())
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
    self.__postinit__()
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
    module_hook.post_graph()
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 27, in <module>
    pkg_base, pkg_dir = get_package_paths('numpy.core')
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 537, in get_package_paths
    file_attr = get_module_file_attribute(package)
  File "C:\Users\ishulman\AppData\Local\Continuum\anaconda3_1505\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 339, in get_module_file_attribute
    raise ImportError
ImportError

所有库均已安装,路径正确,并且代码正在我的计算机上运行。在线研究表明,这与隐藏的导入有关。仍然找不到如何修复我的库的解决方案。我将不胜感激。另外,有没有其他/更简便的方法来使python脚本在不安装Python的情况下在本地运行?

0 个答案:

没有答案