Nuitka: Standalone compilation is missing some sub-modules and sub-packages of the dependencies

  • Nuitka version, full Python version and Platform (Windows, OSX, Linux …)

0.6.8.4 Python: 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] Executable: C:\tools\Anaconda3\envs\nuitka-test\python.exe OS: Windows Arch: x86_64

  • How did you install Nuitka and Python (pip, anaconda, deb, rpm, from source, what is a virtualenv …), this is very important usually.

Installed in a conda environment with: conda create -n nuitka-test python=3.7 conda install nuitka -c conda-forge

  • If possible please supply a Short, Self Contained, Correct, Example that demonstrates the issue i.e a small piece of code which reproduces the issue and can be run with out any other (or as few as possible) external dependencies.
# in file test_nuitka_standalone.py
try:
    # with Python 3.8 this is used and it works
    from importlib import metadata
except ImportError:  # use the backported version with Python 3.7
    import importlib_metadata as metadata


def main():
    print("Success!")


if __name__ == "__main__":
    main()

I tried a normal standalone comiplation with: python -m nuitka --standalone .\test_nuitka_standalone.py and python -m nuitka --standalone --follow-imports .\test_nuitka_standalone.py

and also hinted compilation: python .\get-hints.py .\test_nuitka_standalone.py python .\nuitka-hints.py .\test_nuitka_standalone.py

In both cases, the compilation finishes without errors. However, once I try to run the script, I get the following error:

Traceback (most recent call last): File “C:\Users\user\Projects\SCANNE~1\nuitka\TEST_N1.DIS\test_nuitka_standalone.py”, line 3, in <module> ImportError: cannot import name ‘metadata’ from ‘importlib’ (unknown location)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\Users\user\Projects\nuitka\TEST_N1.DIS\test_nuitka_standalone.py”, line 5, in <module> File “<frozen importlib._bootstrap>”, line 983, in find_and_load File “<frozen importlib._bootstrap>”, line 967, in find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 677, in load_unlocked File "C:\Users\user\Projects\nuitka\TEST_N1.DIS\importlib_metadata_init.py", line 623, in <module importlib_metadata> File "C:\Users\user\Projects\nuitka\TEST_N1.DIS\importlib_metadata_init.py", line 585, in version File "C:\Users\user\Projects\nuitka\TEST_N1.DIS\importlib_metadata_init.py", line 558, in distribution File “C:\Users\user\Projects\nuitka\TEST_N1.DIS\importlib_metadata_init_.py”, line 215, in from_name importlib_metadata.PackageNotFoundError: No package metadata was found for importlib_metadata

  • If this is a regression (used to work in an earlier version of Nuitka), please note what you know about that.

I did not try earlier versions of Nuitka. I tried, however, the current release candidate: 0.6.9rc5, which also did not work.

I also encountered this error with some other packages. The package itself was included in the compiled binary, but some sub-packages or sub-modules were missing.

Still not sure if this is indeed a bug in Nuitka, or whether I am missing some command line arguments.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 23 (15 by maintainers)

Most upvoted comments

Any updates on it?

The approach need not be limited to a specific module. I will make it detect other modules doing similar stuff too. What I am thinking is to add that kind of support. That will in fact lower the run time burden as well, since these calls tend to be expensive.

I started the work you are referring to, and extended it, but it’s not finished. And just to get the version number, it’s pretty much overkill anyway.