Nuitka: Package programs have relative import fails when compiled
When I run create an executable with nuitka --standalone, the resulting executable gives errors about relative imports.
- Nuitka version:
> python -m nuitka --version
0.6.18.4
Commercial: None
Python: 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]
Flavor: Unknown
Executable: C:\Users\Jonathan\AppData\Local\Programs\Python\Python39\python.exe
OS: Windows
Arch: x86_64
-
Installed from
Nuitka-6.1.184.win-amd64.py39.msi -
Code that I tried to compile: https://github.com/jonorthwash/randomtest
-
Output of
nuitka --standalone MyApp:
>nuitka --standalone MyApp
Nuitka-Options:INFO: Used command line options: --standalone MyApp
Nuitka:INFO: Starting Python compilation with Nuitka '0.6.18.4' on Python '3.9' commercial None.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'tkinter' added '_tkinter'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'socket' added '_socket'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'ctypes' added '_ctypes'.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: cl (cl).
Nuitka-Scons:INFO: Compiled 10 C files using clcache with 0 cache hits and 10 cache misses.
Nuitka-Plugins:INFO: data-files: Included data file 'lib2to3\Grammar3.9.9.final.0.pickle' due to package data for 'lib2to3.pgen2'.
Nuitka-Plugins:INFO: data-files: Included data file 'lib2to3\PatternGrammar3.9.9.final.0.pickle' due to package data for 'lib2to3.pgen2'.
Nuitka:INFO: Keeping build directory 'MyApp.build'.
Nuitka:INFO: Successfully created 'MyApp.dist\\MyApp.exe'.
- Output of running the script via
python -m MyApp(expected):
>python -m MyApp
testing modules
running module
running util.tools.Tool from within module
init Tool
testing util
init Tool
- Output of running executable (unexpected):
>MyApp.dist\MyApp.exe
Traceback (most recent call last):
File "Z:\2021-12-20\MyApp.dist\__main__.py", line 3, in <module>
ImportError: attempted relative import with no known parent package
This issue may be related to #493 or #869. I’m probably just doing something wrong, but @kayhayen suggested in Nuitka-chat/community that I submit an issue about this.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (16 by maintainers)
I pushed to factory a change that makes this work. The only horror I have is how to explain this to people.