使用 Nuitka for Python 应用程序时出错,该应用程序使用 Numpy、Pandas 和 Plotly

Jac*_*123 5 windows numpy python-3.x mingw-w64 nuitka

我开发了一个 PyQT5 应用程序,它也使用 Numpy、Pandas 和 Plotly。为了将其打包,我决定使用 Nuitka,但是由于该产品面向不熟悉 Python 的最终用户,我想确保解释器与应用程序一起打包为单个二进制文件(类似于 PyInstaller) 。

我正在运行以下命令,但是遇到了错误,我正在努力找出如何修复:

$ python -m nuitka --standalone --show-progress --recurse-all --plugin-enable=numpy main.py
Run Code Online (Sandbox Code Playgroud)

我正在使用 PyCharm,所有库都位于项目目录的虚拟环境中。我使用的Python版本是3.9。

在 Windows 中生成了可执行二进制文件,但是在运行时我收到以下错误消息:

C:\Users\user\PycharmProjects\PlotlyExample\main.dist>main
Traceback (most recent call last):
  File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\__init__.py", line 22, in <module numpy.core>
  File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\multiarray.py", line 12, in <module numpy.core.multiarray>
  File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\overrides.py", line 7, in <module numpy.core.overrides>
ImportError: LoadLibraryExW 'C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\_multiarray_umath.pyd' 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\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\main.py", line 5, in <module>
  File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\__init__.py", line 140, in <module numpy>
  File "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\__init__.py", line 48, in <module numpy.core>
ImportError:

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

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

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.9 from "C:\Users\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\python.exe"
  * The NumPy version is: "1.19.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: LoadLibraryExW 'C:\Users\\user\PYCHAR~1\PLOTLY~1\MAIN~1.DIS\numpy\core\_multiarray_umath.pyd' failed: The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)

示例代码: https://pastebin.com/RjRYUk0C

有任何想法吗?谢谢!