简体   繁体   English

Pyinstaller无法创建.exe文件

[英]Pyinstaller can't create the .exe file

I wanted to convert my python code into an executable and came across Pyinstaller package. However while running pyinstaller --onefile my_python_code.py from my cmd prompt it throws an ImportErrorWhenRunningHook for with numpy. I don't know where/ how to find the required module in my machine as per the error instructions.我想将我的 python 代码转换为可执行文件并遇到 Pyinstaller package。但是,在从我的 cmd 提示运行pyinstaller --onefile my_python_code.py时,它会抛出 ImportErrorWhenRunningHook for with numpy。我不知道在哪里/如何找到所需的根据错误说明在我的机器中安装模块。 Can anybody please help me understand the error message and overcome the challenge?任何人都可以帮助我理解错误信息并克服挑战吗?

edit:编辑:

... 281436 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks'... c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. ... 281436 信息:从“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks”加载模块挂钩“hook-matplotlib.backends.py”... c:\programdata\anaconda3 \envs\geo_env\lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package 导入失败,因此 Intel(R) MKL 初始化确保其在 Gnu 条件下的正确开箱即用操作OpenMP 已经被 Python 进程加载了不放心。 Please install mkl-service package, see http://github.com/IntelPython/mkl-service from.请安装 mkl-service package,参见http://github.com/IntelPython/mkl-service from。 import distributor_init Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init .py", line 22, in from.导入distributor_init Traceback(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init.py ”,第 22 行,来自。 import multiarray File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py", line 12, in from.从中导入多阵列文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py”,第 12 行。 import overrides File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: DLL load failed: The specified module could not be found.导入覆盖文件“c:\找不到模块。

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "", line 1, in File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib_ init _.py", line 107, in from.回溯(最近调用最后):文件“”,第 1 行,在文件“c:\programdata\anaconda3\envs\ geo_env \lib\site-packages\matplotlib_init_.py”,第 107 行,在 from. import cbook, rcsetup File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib\cbook_ init _.py", line 28, in import numpy as np File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py", line 140, in from. import cbook, rcsetup File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib\cbook_ init _.py", line 28, in import numpy as np File "c:\programdata\anaconda3\envs \geo_env\lib\site-packages\numpy_ init _.py",第 140 行,来自。 import core File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init _.py", line 48, in raise ImportError(msg) ImportError:导入核心文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init_.py ”,第 48 行,在 raise ImportError(msg) ImportError 中:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是由于您的设置问题或 NumPy 的安装方式所致。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除技巧:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * The NumPy version is: "1.19.1" Python版本是:Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * NumPy版本是:"1.19.1"

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: DLL load failed: The specified module could not be found.原来的错误是:DLL加载失败:找不到指定的模块。

281586 INFO: Loading module hook 'hook-matplotlib.py' from 'c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks'... c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. 281586 信息:从“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks”加载模块挂钩“hook-matplotlib.py”... c:\programdata\anaconda3\envs\geo_env\ lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package 导入失败,因此英特尔(R) MKL 初始化确保在 Gnu OpenMP 已经加载的情况下正确的开箱即用操作通过Python过程不放心。 Please install mkl-service package, see http://github.com/IntelPython/mkl-service from.请安装 mkl-service package,参见http://github.com/IntelPython/mkl-service from。 import distributor_init Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init .py", line 22, in from.导入distributor_init Traceback(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init.py ”,第 22 行,来自。 import multiarray File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py", line 12, in from.从中导入多阵列文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py”,第 12 行。 import overrides File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: DLL load failed: The specified module could not be found.导入覆盖文件“c:\找不到模块。

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "", line 1, in File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib_ init _.py", line 107, in from.回溯(最近调用最后):文件“”,第 1 行,在文件“c:\programdata\anaconda3\envs\ geo_env \lib\site-packages\matplotlib_init_.py”,第 107 行,在 from. import cbook, rcsetup File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib\cbook_ init _.py", line 28, in import numpy as np File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py", line 140, in from. import cbook, rcsetup File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\matplotlib\cbook_ init _.py", line 28, in import numpy as np File "c:\programdata\anaconda3\envs \geo_env\lib\site-packages\numpy_ init _.py",第 140 行,来自。 import core File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init _.py", line 48, in raise ImportError(msg) ImportError:导入核心文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init_.py ”,第 48 行,在 raise ImportError(msg) ImportError 中:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是由于您的设置问题或 NumPy 的安装方式所致。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除技巧:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * The NumPy version is: "1.19.1" Python版本是:Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * NumPy版本是:"1.19.1"

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: DLL load failed: The specified module could not be found.原来的错误是:DLL加载失败:找不到指定的模块。

281757 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks'... 281769 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks'... c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. 281757 信息:从“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks”加载模块钩子“hook-multiprocessing.util.py”... 281769 信息:加载模块钩子“hook-” numpy.core.py' 来自 'c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks'... c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py:138: UserWarning: mkl-service package 导入失败,因此英特尔(R) MKL 初始化确保其在 Gnu OpenMP 已经被 Python 进程加载的情况下正确的开箱即用操作无法保证。 Please install mkl-service package, see http://github.com/IntelPython/mkl-service from.请安装 mkl-service package,参见http://github.com/IntelPython/mkl-service from。 import distributor_init c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init .py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. import distributor_init c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init .py:138: UserWarning: mkl-service package 导入失败,因此英特尔(R) MKL 初始化确保其正确的输出在 Gnu OpenMP 已经被 Python 进程加载的情况下,盒子的运行是不可靠的。 Please install mkl-service package, see http://github.com/IntelPython/mkl-service from.请安装 mkl-service package,参见http://github.com/IntelPython/mkl-service from。 import distributor_init Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init .py", line 22, in from.导入distributor_init Traceback(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init.py ”,第 22 行,来自。 import multiarray File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py", line 12, in from.从中导入多阵列文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py”,第 12 行。 import overrides File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: DLL load failed: The specified module could not be found.导入覆盖文件“c:\找不到模块。

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "", line 2, in File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py", line 140, in from.回溯(最近调用最后):文件“”,第 2 行,在文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\ numpy_init_.py ”,第 140 行,在 from. import core File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init _.py", line 48, in raise ImportError(msg) ImportError:导入核心文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init_.py ”,第 48 行,在 raise ImportError(msg) ImportError 中:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是由于您的设置问题或 NumPy 的安装方式所致。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除技巧:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * The NumPy version is: "1.19.1" Python版本是:Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * NumPy版本是:"1.19.1"

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: DLL load failed: The specified module could not be found.原来的错误是:DLL加载失败:找不到指定的模块。

Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init _.py", line 22, in from.追溯(最近一次调用最后一次):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init_.py ”,第 22 行,来自。 import multiarray File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py", line 12, in from.从中导入多阵列文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\multiarray.py”,第 12 行。 import overrides File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core\overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: DLL load failed: The specified module could not be found.导入覆盖文件“c:\找不到模块。

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\pkgutil.py", line 493, in find_loader spec = importlib.util.find_spec(fullname) File "c:\programdata\anaconda3\envs\geo_env\lib\importlib\util.py", line 94, in find_spec parent = import (parent_name, fromlist=[' path ']) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy_ init _.py", line 140, in from.回溯(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\pkgutil.py”,第 493 行,在 find_loader spec = importlib.util.find_spec(fullname) 文件“c:\programdata\ anaconda3\envs\geo_env\lib\importlib\util.py",第 94 行,在 find_spec parent = import (parent_name, fromlist=[' path ']) File "c:\programdata\anaconda3\envs\geo_env\lib\site -packages\numpy_ init _.py",第 140 行,来自。 import core File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\core_ init _.py", line 48, in raise ImportError(msg) ImportError:导入核心文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\numpy\ core_init_.py ”,第 48 行,在 raise ImportError(msg) ImportError 中:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是由于您的设置问题或 NumPy 的安装方式所致。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除技巧:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * The NumPy version is: "1.19.1" Python版本是:Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * NumPy版本是:"1.19.1"

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: DLL load failed: The specified module could not be found.原来的错误是:DLL加载失败:找不到指定的模块。

The above exception was the direct cause of the following exception:上述异常是以下异常的直接原因:

Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\utils\hooks_ init _.py", line 289, in get_module_file_attribute loader = pkgutil.find_loader(package) File "c:\programdata\anaconda3\envs\geo_env\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'>:回溯(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\utils\ hooks_init_.py ”,第 289 行,在 get_module_file_attribute loader = pkgutil.find_loader(package )文件“c:\ 'numpy.core' 的加载程序(<class 'ImportError'>:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是由于您的设置问题或 NumPy 的安装方式所致。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除技巧:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * The NumPy version is: "1.19.1" Python版本是:Python3.7 from "c:\programdata\anaconda3\envs\geo_env\python.exe" * NumPy版本是:"1.19.1"

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: DLL load failed: The specified module could not be found.原来的错误是:DLL加载失败:找不到指定的模块。 ) )

The above exception was the direct cause of the following exception:上述异常是以下异常的直接原因:

Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py", line 409, in _load_hook_module self.hook_module_name, self.hook_filename) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\compat.py", line 593, in importlib_load_source return mod_loader.load_module() File "", line 407, in _check_name_wrapper回溯(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py”,第 409 行,在 _load_hook_module self.hook_module_name, self.hook_filename) 文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\compat.py”,第 593 行,在 importlib_load_source 返回 mod_loader.load_module() 文件“”,第 407 行,在 _check_name_wrapper
File "", line 907, in load_module File "", line 732, in load_module File "", line 265, in _load_module_shim File "", line 696, in _load File "", line 677, in load_unlocked File "", line 728, in exec_module File "", line 219, in call_with_frames_removed File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 29, in pkg_base, pkg_dir = get_package_paths('numpy.core') File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\utils\hooks_ init .py", line 506, in get_package_paths file_attr = get_module_file_attribute(package) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\utils\hooks_ init .py", line 308, in get_module_file_attribute raise ImportError('Unable to load module attribute') from e ImportError: Unable to load module attribute文件“”,第 907 行,在 load_module 文件“”,第 732 行,在 load_module 文件“”,第 265 行,在 _load_module_shim 文件“”,第 696 行,在 _load 文件“”,第 677 行,在load_unlocked 文件“”,行728,在exec_module文件“”,第219行,在call_with_frames_removed文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py”,第29行,在pkg_base ,pkg_dir = get_package_paths(' numpy.core ')文件“c:\ ) 文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\utils\ hooks_init.py ”,第 308 行,在 get_module_file_attribute raise ImportError('Unable to load module attribute') from e ImportError:无法加载模块属性

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "c:\programdata\anaconda3\envs\geo_env\lib\runpy.py", line 193, in run_module_as_main " main ", mod_spec) File "c:\programdata\anaconda3\envs\geo_env\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\envs\geo_env\Scripts\pyinstaller.exe_ main .py", line 7, in File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller_ main .py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller_ main _.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build exec(code, spec_回溯(最近调用最后):文件“c:\programdata\anaconda3\envs\geo_env\lib\runpy.py”,第 193 行,在run_module_as_main“ main ”,mod_spec 中)文件“c:\programdata\anaconda3\envs\ geo_env\lib\runpy.py",第 85 行,在run_code exec(code, run_globals) 文件“C:\ProgramData\Anaconda3\envs\geo_env\Scripts\pyinstaller.exe_ main .py”,第 7 行,在文件“c :\programdata\anaconda3\envs\geo_env\lib\site-packages\ PyInstaller_main.py ", 第 114 行,在运行 run_build(pyi_config, spec_file, **vars(args)) File "c:\programdata\anaconda3\envs \geo_env\lib\site-packages\ PyInstaller_main_.py ",第 65 行,在 run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\programdata\anaconda3\envs\geo_env\ lib\site-packages\PyInstaller\building\build_main.py",第 720 行,在主构建中(specfile,kw.get('distpath'),kw.get('workpath'),kw.get('clean_build') ) 文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py”,第 667 行,在构建执行程序中namespace) File "C:\Users\pandas10\Desktop\sa_fmcg_forecast\py_exe\fmcg_forecast.spec", line 17, in noarchive=False) File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py", line 242, in init self.命名空间)文件“C:\Users\pandas10\Desktop\sa_fmcg_forecast\py_exe\fmcg_forecast.spec”,第 17 行,noarchive=False)文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller \building\build_main.py”,第 242 行,在init self 中。 postinit () File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in postinit self.assemble() File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py", line 419, in assemble self.graph.process_post_graph_hooks() File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\analysis.py", line 367, in process_post_graph_hooks module_hook.post_graph() File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py", line 447, in post_graph self._load_hook_module() File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py", line 413, in _load_hook_module self.hook_module_name, self.hook_filename) PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_numpy_core required by hook for module c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\h postinit () File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in postinit self.assemble() File "c:\programdata\anaconda3\ envs\geo_env\lib\site-packages\PyInstaller\building\build_main.py", line 419, in assemble self.graph.process_post_graph_hooks() File "c:\programdata\anaconda3\envs\geo_env\lib\site-packages\ PyInstaller\depend\analysis.py”,第 367 行,在 process_post_graph_hooks module_hook.post_graph() 文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py”,第 447 行,在 post_graph self._load_hook_module() 文件“c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\depend\imphook.py”,第 413 行,在 _load_hook_module self.hook_module_name, self.hook_filename) PyInstaller。 exceptions.ImportErrorWhenRunningHook:无法导入模块 c 的挂钩所需的模块 __PyInstaller_hooks_0_numpy_core:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\h ook-numpy.core.py.确定-numpy.core.py。 Please check whether module __PyInstaller_hooks_0_numpy_core actually exists and whether the hook is compatible with your version of c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.请检查模块 __PyInstaller_hooks_0_numpy_core 是否实际存在以及钩子是否与您的版本兼容 c:\programdata\anaconda3\envs\geo_env\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py: 你可能想要在手册中阅读有关挂钩的更多信息,并提供拉取请求以改进 PyInstaller。

Note: I am using Anaconda and working in a separate environment than python base or default .注意:我正在使用 Anaconda 并在与 python base 或 default不同的环境中工作。

After reading the whole log file, it seems like the installer did not download all the packages.阅读整个日志文件后,安装程序似乎没有下载所有包。 I strongly recommend uninstalling the package and reinstalling it.我强烈建议卸载 package 并重新安装它。

For uninstalling - Open a command or terminal window (depending on the operating system) cd into the project directory.卸载 - 打开命令或终端 window(取决于操作系统) cd 进入项目目录。 pip uninstall pyinstaller pip 卸载pyinstaller

And to reinstall - If u r using PyCharm, just go to terminal on the bottom and type - pip install pyinstaller And to reinstall - If u r using PyCharm, just go to terminal on the bottom and type - pip install pyinstaller

If u r using other things (I don't know about what you may be using) - On Windows - press Windows Key + R and type cmd If u r using other things (I don't know about what you may be using) - On Windows - press Windows Key + R and type cmd

On Mac - go to Finder/ Applications/ Terminal (I may be wrong)在 Mac 上 - go 到 Finder/应用程序/终端(我可能错了)

Now type the command - pip install pyinstaller现在输入命令 - pip install pyinstaller

See the installation process and the packages being installed, if there is already a package installed, it will skip its installation, and if one isn't installed, pip will install it.查看安装过程和正在安装的软件包,如果已经安装了package,则跳过安装,如果没有安装,则安装pip。

Based on the log, obviously you are using the Anaconda python distribution.根据日志,显然您使用的是 Anaconda python 发行版。 the Import error is happening cause the mkl-service's DLL can't be found, which should be located in:发生导入错误是因为找不到 mkl-service 的 DLL,它应该位于:

C:\Users\\anaconda3\Library\bin C:\用户\\anaconda3\图书馆\bin

or或者

C:\Users<username>\anaconda3\envs\<env_name>\Library\bin C:\Users<用户名>\anaconda3\envs\<env_name>\Library\bin

The most likely reason why the necessary DLLs can't be found (assuming mkl-service has been installed correctly) is the absence of the above directory in the PATH environment variable.找不到必要的 DLL(假设 mkl-service 已正确安装)的最可能原因是 PATH 环境变量中缺少上述目录。

The mentioned path is usually prepended to the PATH by the Anaconda Prompt before build, so one solution is to run the command in the Anaconda Prompt.提到的路径通常在构建之前由 Anaconda 提示符添加到 PATH,因此一种解决方案是在 Anaconda 提示符中运行命令。

Other solutions include:其他解决方案包括:

  1. Either append the mentioned directory to the PATH globally (by editing the PATH variable in the Windows Settings), or将 append 提到的目录全局添加到 PATH(通过编辑 Windows 设置中的 PATH 变量),或
  2. Find a way to temporarily append it to the PATH (for the duration of your code's execution), specific to your development environment.找到一种方法将它临时 append 到 PATH(在代码执行期间),特定于您的开发环境。
please help django project to pyinstaller ImportErrorWhenRunningHook error

(base) C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG>pyinstaller --onefile --icon=PAPS_Logo.ico manage.py
2167 INFO: PyInstaller: 5.6.2
2167 INFO: Python: 3.8.8 (conda)
2169 INFO: Platform: Windows-10-10.0.22621-SP0
2170 INFO: wrote C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG\manage.spec
2173 INFO: UPX is not available.
2175 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Desktop\\work\\youngjae\\Samsung_Hospital2\\Local\\ECG']
pygame 2.1.2 (SDL 2.0.18, Python 3.8.8)
Hello from the pygame community. https://www.pygame.org/contribute.html
4439 INFO: checking Analysis
4439 INFO: Building Analysis because Analysis-00.toc is non existent
4440 INFO: Initializing module dependency graph...
4449 INFO: Caching module graph hooks...
4458 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
4466 INFO: Analyzing base_library.zip ...
14853 INFO: Loading module hook 'hook-heapq.py' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
15297 INFO: Loading module hook 'hook-encodings.py' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
20044 INFO: Loading module hook 'hook-pickle.py' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
21505 INFO: Caching module dependency graph...
21667 INFO: running Analysis Analysis-00.toc
21684 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\ProgramData\Anaconda3\python.exe
21873 INFO: Analyzing C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG\manage.py
22108 INFO: Loading module hook 'hook-django.py' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
3243 WARNING: Failed to collect submodules for 'django.contrib.gis.admin' because importing 'django.contrib.gis.admin' raised: django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
32438 INFO: Determining a mapping of distributions to packages...
340593 INFO: Packages required by django:
['pytz', 'sqlparse']
340594 INFO: Django root directory C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG\djangoproject
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\subproc\django_import_finder.py", line 24, in <module>
    django.setup()
  File "C:\ProgramData\Anaconda3\lib\site-packages\django\__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 79, in __getattr__
    self._setup(name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG\djangoproject\settings.py", line 250, in <module>
    STATIC_DIR = os.path.join(BASE_DIR, 'static')
  File "C:\ProgramData\Anaconda3\lib\ntpath.py", line 78, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not WindowsPath
341077 INFO: Collecting Django migration scripts.
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 394, in get_module_file_attribute
    filename = _get_module_file_attribute(package)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 368, in wrapped
    return call(function, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 337, in call
    return isolated.call(function, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 275, in call
    raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output)
RuntimeError: Child process call to _get_module_file_attribute() failed with:
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\isolated\_child.py", line 63, in run_next_command
    output = function(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 389, in _get_module_file_attribute
    p = importlib.import_module(package)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'corsheaders'

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

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 387, in _load_hook_module
    self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 609, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 962, in load_module
  File "<frozen importlib._bootstrap_external>", line 787, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-django.py", line 71, in <module>
    mod_dir = os.path.dirname(hooks.get_module_file_attribute(mod_name))
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 396, in get_module_file_attribute
    raise ImportError(f"Failed to obtain the __file__ attribute of package/module {package}!") from e
ImportError: Failed to obtain the __file__ attribute of package/module corsheaders!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\Scripts\pyinstaller-script.py", line 10, in <module>
    sys.exit(run())
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 179, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 60, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 963, in main
    build(specfile, distpath, workpath, clean_build)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 885, in build
    exec(code, spec_namespace)
  File "C:\Users\user\Desktop\work\youngjae\Samsung_Hospital2\Local\ECG\manage.spec", line 7, in <module>
    a = Analysis(
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 410, in __init__
    self.__postinit__()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 173, in __postinit__
    self.assemble()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 573, in assemble
    priority_scripts.append(self.graph.add_script(script))
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 268, in add_script
    self._top_script_node = super().add_script(pathname)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1433, in add_script
    self._process_imports(n)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
    target_modules = self._safe_import_hook(*import_info, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 381, in _safe_import_hook
    return super()._safe_import_hook(target_module_partname, source_module, target_attr_names, level, edge_attr)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
    target_modules = self.import_hook(
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
    target_package, target_module_partname = self._find_head_package(
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
    target_package = self._safe_import_module(
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 428, in _safe_import_module
    return super()._safe_import_module(module_basename, module_name, parent_package)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2062, in _safe_import_module
    self._process_imports(n)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
    target_modules = self._safe_import_hook(*import_info, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 368, in _safe_import_hook
    excluded_imports = self._find_all_excluded_imports(source_module.identifier)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 356, in _find_all_excluded_imports
    excluded_imports.update(module_hook.excludedimports)
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 320, in __getattr__
    self._load_hook_module()
  File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 390, in _load_hook_module
    raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename)
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_django required by hook for module C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-django.py. Please check whether module __PyInstaller_hooks_0_django actually exists and whether the hook is compatible with your version of C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-django.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM