【问题标题】:Anaconda Python - trouble creating a .exe file from a .pyAnaconda Python - 从 .py 创建 .exe 文件时遇到问题
【发布时间】:2020-08-09 03:42:14
【问题描述】:

我是新程序员,当我尝试将我的 .py 文件转换为可执行的 .exe 文件时,我收到以下错误。

我的numpy版本是1.19.1(我已经卸载重新安装了)。

我的 Anaconda 版本是 1.9.12

PYTHONPATH 没问题。

尝试获取.exe文件时出现如下错误:

Running auto-py-to-exe v2.7.6
Building directory: C:\Users\User\AppData\Local\Temp\tmp30rpmpfm
Provided command: pyinstaller --noconfirm --onedir --windowed  "C:/Users/User/Documents/Python/Scripts/Italiano/conjugacion_verbos_presente/auxiliar.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --windowed C:/Users/User/Documents/Python/Scripts/Italiano/conjugacion_verbos_presente/auxiliar.py --distpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\application --workpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\build --specpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm

520727 INFO: PyInstaller: 3.6
520732 INFO: Python: 3.7.6 (conda)
520736 INFO: Platform: Windows-10-10.0.18362-SP0
520746 INFO: wrote C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\auxiliar.spec
520753 INFO: UPX is not available.
520761 INFO: Extending PYTHONPATH with paths
['C:\\Users\\User\\Documents\\Python\\Scripts\\Italiano',
 'C:\\Users\\User\\AppData\\Local\\Temp\\tmp30rpmpfm']
520765 INFO: checking Analysis
520769 INFO: Building Analysis because Analysis-01.toc is non existent
520774 INFO: Reusing cached module dependency graph...
520878 INFO: Caching module graph hooks...
521005 INFO: running Analysis Analysis-01.toc
521011 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Anaconda3\python.exe
521620 INFO: Analyzing C:\Users\User\Documents\Python\Scripts\Italiano\conjugacion_verbos_presente\auxiliar.py
527431 INFO: Processing pre-find module path hook   distutils
527438 INFO: distutils: retargeting to non-venv dir 'C:\\Anaconda3\\lib'
533043 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
534572 INFO: Processing pre-find module path hook   site
534577 INFO: site: retargeting to fake-dir 'C:\\Anaconda3\\lib\\site-packages\\PyInstaller\\fake-modules'
547576 INFO: Processing module hooks...
547582 INFO: Loading module hook "hook-distutils.py"...
547591 INFO: Loading module hook "hook-encodings.py"...
547763 INFO: Loading module hook "hook-importlib_metadata.py"...
547772 INFO: Loading module hook "hook-lib2to3.py"...
547785 INFO: Loading module hook "hook-numpy.core.py"...
An error occurred while packaging
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
    from . import multiarray
  File "C:\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
    from . import overrides
  File "C:\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda3\lib\pkgutil.py", line 493, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "C:\Anaconda3\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:`enter code here`
  1. Check that you expected to use Python3.7 from "C:\Anaconda3\python.exe",`enter code here`
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.1" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.


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

Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 320, in get_module_file_attribute
    loader = pkgutil.find_loader(package)
  File "C:\Anaconda3\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'>: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "C:\Anaconda3\python.exe",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.1" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.
)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\Desktop\auto-py-to-exe-master\auto_py_to_exe\packaging.py", line 131, in package
    run_pyinstaller()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
    exec(code, spec_namespace)
  File "C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\auxiliar.spec", line 17, in <module>
    noarchive=False)
  File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
    self.__postinit__()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 422, in assemble
    self.graph.process_post_graph_hooks()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 311, in process_post_graph_hooks
    module_hook.post_graph()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 417, in post_graph
    self._load_hook_module()
  File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 384, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 797, 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:\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 29, in <module>
    pkg_base, pkg_dir = get_package_paths('numpy.core')
  File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 537, in get_package_paths
    file_attr = get_module_file_attribute(package)
  File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 339, in get_module_file_attribute
    raise ImportError
ImportError

Project output will not be moved to output folder
Complete.

【问题讨论】:

  • 您是否按照输出中的说明进行操作?

标签: python numpy anaconda conda py2exe


【解决方案1】:

将 .py 转换为 .exe

安装 auto-py-to-exe 库

pip install auto-py-to-exe

运行以下命令将.py转换为.exe

python -m auto_py_to_exe first.py
按照说明操作

【讨论】:

  • 这就是所做的并且得到一个窗口说:检测到致命错误。执行脚本失败
  • 并且程序在创建 .exe 文件时给了我这个:49032 警告:未找到 lib:C:\Anaconda3\Library\bin\mkl_blacs_msmpi_ilp64.dll 的 msmpi.dll 依赖项 49119 警告: 找不到库:C:\Anaconda3\Library\bin\mkl_pgi_thread.dll 的 pgf90rtl.dll 依赖项 49125 警告:找不到库:C:\Anaconda3\Library\bin\mkl_pgi_thread.dll 的 pgf90.dll 依赖项 49140 警告:lib未找到:C:\Anaconda3\Library\bin\mkl_pgi_thread.dll 的 pgc14.dll 依赖项 49153 警告:找不到库:C:\Anaconda3\Library\bin\mkl_blacs_mpich2_ilp64.dll 的 mpich2mpi.dll 依赖项跨度>
  • 请尝试从通用命令行选项中使用。
猜你喜欢
  • 2022-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-19
  • 1970-01-01
  • 1970-01-01
  • 2023-02-04
  • 1970-01-01
相关资源
最近更新 更多