构建警告
Nuitka-Plugins:警告:dll 文件:按“numpy”的文件名代码进行 DLL 配置未给出结果。要么缺少条件,要么该版本的模块需要添加处理。尽管出现此警告,构建仍成功完成。
运行时错误
ImportError:导入 numpy 时出错:您不应该尝试从以下位置导入 numpy 它的源目录;请退出 numpy 源代码树,然后重新启动 你的Python解释器就在那里。该错误表明该项目错误地尝试从其源目录导入 NumPy,但我已验证我没有从 NumPy 源目录中运行该项目。
最小可重现示例
pyside6-deploy --name DICON -v -f .\main.py
对于涉及的库和python我有以下版本:
Python 3.10.13
Numpy 1.26.4
这是最小的例子:
import sys
import os
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
import numpy as np
if __name__ == "__main__":
print(np.linspace(0,100,100))
执行构建命令后,这是我收到的输出:
INFO:root:[DEPLOY] Start
INFO:root:[DEPLOY] Using python at C:\Users\damie\anaconda3\envs\qutee\python.exe
INFO:root:[DEPLOY] Creating config file C:\Users\damie\OneDrive\Desktop\Damien\AeroDelft\repositories\DCDC-MP-CTRL-PANEL\pysidedeploy.spec
INFO:root:[DEPLOY] No .pyproject file found. Project file not set
INFO:root:[DEPLOY] Installing dependencies
INFO:root:[DEPLOY] package: nuitka==1.5.4 already installed
INFO:root:[DEPLOY] package: ordered_set already installed
INFO:root:[DEPLOY] package: zstandard already installed
INFO:root:[DEPLOY] Creating C:\Users\damie\OneDrive\Desktop\Damien\AeroDelft\repositories\DCDC-MP-CTRL-PANEL\pysidedeploy.spec
INFO:root:[DEPLOY] Deploying application
INFO:root:[DEPLOY] Running Nuitka
Nuitka-Plugins:WARNING: pyside6: Unwanted import of 'tkinter' that is redundant with 'PySide6' encountered. Use '--nofollow-import-to=tkinter' or uninstall it for best compatibility with pure Python execution.
Nuitka-Plugins:WARNING: dll-files: DLL configuration by filename code for 'numpy' did not give a result. Either conditions are missing, or this version of the module needs treatment added.
[DEPLOY] Executed file created in C:\Users\damie\OneDrive\Desktop\Damien\AeroDelft\repositories\DCDC-MP-CTRL-PANEL\main.exe
INFO:root:[DEPLOY] Deployment directory purged
INFO:root:[DEPLOY] End
尝试解决pysidedeploy.spec
中指定numpy,然后使用
main.py
文件代替从
.spec
构建。您可以看到下面的配置:
[app]
# title of your application
title = DICON
# project directory. the general assumption is that project_dir is the parent directory
# of input_file
project_dir = .
# source file path
input_file = C:\Users\damie\OneDrive\Desktop\Damien\AeroDelft\repositories\DCDC-MP-CTRL-PANEL\main.py
# directory where exec is stored
exec_directory = .
# path to .pyproject project file
project_file =
[python]
# python path
python_path = C:\Users\damie\anaconda3\envs\qutee\python.exe
# python packages to install
# ordered-set = increase compile time performance of nuitka packaging
# zstandard = provides final executable size optimization
packages = nuitka==1.5.4,ordered_set,zstandard, numpy==1.26.4
# buildozer = for deploying Android application
android_packages = buildozer==1.5.0,cython==0.29.33
[qt]
# comma separated path to qml files required
# normally all the qml files are added automatically
qml_files =
# excluded qml plugin binaries
excluded_qml_plugins =
# path to pyside wheel
wheel_pyside =
# path to shiboken wheel
wheel_shiboken =
# plugins to be copied to libs folder of the packaged application. comma separated
plugins = platforms_qtforandroid
[nuitka]
# (str) specify any extra nuitka arguments
# eg = extra_args = --show-modules --follow-stdlib
extra_args = --quiet --noinclude-qt-translations=True
[buildozer]
# build mode
# possible options = [release, debug]
# release creates an aab, while debug creates an apk
mode = debug
# contrains path to pyside6 and shiboken6 recipe dir
recipe_dir =
# path to extra qt android jars to be loaded by the application
jars_dir =
# if empty uses default ndk path downloaded by buildozer
ndk_path =
# if empty uses default sdk path downloaded by buildozer
sdk_path =
# modules used. comma separated
modules =
# other libraries to be loaded. comma separated.
# loaded at app startup
local_libs = plugins_platforms_qtforandroid
# architecture of deployed platform
# possible values = ["aarch64", "armv7a", "i686", "x86_64"]
arch =
问题:
问题,我认为我的问题是由我使用 pip 安装 Numpy 引起的。所以我使用pip uninstall numpy
卸载,然后使用
conda install numpy
再次安装。这解决了我的 DLL 问题。