question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  • 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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
MrYachacommented, Aug 24, 2021

Any updates on it?

1reaction
kayhayencommented, Mar 26, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

packages - How to design re-usable sub-modules?
There was a recent question asking about how to design modular packages: Declaring Package with dependencies in multiples files?
Read more >
python - setup with submodules dependencies - Stack Overflow
My question is not about finding (sub)packages with setuptools , nor is it about relative imports. This is our structure: package-repo/ setup.py ...
Read more >
Python import: Advanced Techniques and Tips
In general, submodules and subpackages aren't imported when you import a package. ... gives you some overview over the internal dependencies of your...
Read more >
Packaging namespace packages
Namespace packages allow you to split the sub-packages and modules within a single package ... Namespace packages can be useful for a large...
Read more >
spack package — Spack 0.20.0.dev0 documentation
This gives packages like Python and others that follow the extension model a way to implement common environment or compile-time settings for dependencies....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found