ChenMo
ChenMo

Reputation: 1

Applications packaged with nuitka cannot run

I am using Nuitka to package my PyQt5 application and running it in source code without any exceptions. But running after packaging will report an error:

📢 Tips: QFluentWidgets Pro is now released. Click https://qfluentwidgets.com/pages/pro to learn more about it.

Traceback (most recent call last):
  File "C:\Users\18079\DOCUME~1\DOWNLO~1\MUSICD~1.DIS\MusicDownloader.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "C:\Users\18079\DOCUME~1\DOWNLO~1\MUSICD~1.DIS\window\main.py", line 6, in <module window.main>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "C:\Users\18079\DOCUME~1\DOWNLO~1\MUSICD~1.DIS\Interface\settings.py", line 11, in <module Interface.settings>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "C:\Users\18079\DOCUME~1\DOWNLO~1\MUSICD~1.DIS\helper\localmusicsHelper.py", line 9, in <module helper.localmusicsHelper>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "C:\Users\18079\DOCUME~1\DOWNLO~1\MUSICD~1.DIS\fleep\__init__.py", line 15, in <module fleep>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\18079\\DOCUME~1\\DOWNLO~1\\MUSICD~1.DIS\\fleep\\data.json'

Before reinstalling the system, I was able to package and run it normally, but now it cannot run under any circumstances, even with administrator privileges. This is my packaging command:

nuitka --standalone --plugin-enable=pyqt5 --windows-icon-from-ico=icon.ico MusicDownloader.py

This is the output of my execution of nuitka -- version:

C:\Users\18079>nuitka --version
2.3.4
Commercial: None
Python: 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
Flavor: CPython Official
Executable: C:\Users\18079\AppData\Local\Programs\Python\Python311\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 11
Nuitka-Scons: Non downloaded winlibs-gcc 'C:\Users\18079\Documents\mingw64\bin\gcc.exe' is being ignored, Nuitka is very
Nuitka-Scons: dependent on the precise one.
Version C compiler: ~\AppData\Local\Nuitka\Nuitka\Cache\DOWNLO~1\gcc\x86_64\13.2.0-16.0.6-11.0.1-msvcrt-r1\mingw64\bin\gcc.exe (gcc 13.2.0).

I tried running on different computers, but none of them worked.

Upvotes: 0

Views: 141

Answers (1)

Ahmed Farouk
Ahmed Farouk

Reputation: 29

It sounds like that the error is because you do not include data.json inside the build folder.

According to Nuitka docs, you should tell Nuitka about data files that you use as it does not track them implicitly.

So your command should be:

    nuitka --standalone --plugin-enable=pyqt5 --windows-icon-from-ico=icon.ico --include-data-files=/path/to/file/data.json=destnation_folder_name/data.json MusicDownloader.py

Upvotes: 0

Related Questions