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.

Compiling package in module mode with Anaconda 3.x produces extension module that fails to load

See original GitHub issue

Environment Details

  • Nuitka version, full Python version and Platform (Windows, OSX, Linux …)
$ python -m nuitka --version
0.6.17.3
Commercial: None
Python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) 
Executable: /opt/conda/bin/python
OS: Linux
Arch: x86_64
  • How did you install Nuitka and Python

    I am using Anaconda Python; Nuitka was installed via python -m pip install nuitka

  • The specific PyPI names and versions

    We have many different dependencies in this project, but here are a few:

numpy                         1.20.3
pandas                        1.3.4
pydantic                      1.8.2
scikit-learn                  0.24.2

Problem

I am new to Nuitka (very cool solution) and am trying to compile an entire package into a single executable file. I attempted to do so with a command like this, from within a directory where the code for the package (which hasn’t been otherwise installed or compiled yet) lives:

python -m nuitka --module package --include-package=package

After running that command, I find the following in my directory:

drwsrwsr-x 1 owner users   4096       Oct 24 20:52 package
drwsrwsr-x 1 owner users   65536      Oct 24 20:59 package.build
-rw-rw-r-- 1 owner users   6823728    Oct 24 21:00 package.cpython-39-x86_64-linux-gnu.so
-rw-rw-r-- 1 owner users   5819       Oct 24 21:00 package.pyi

I then take the original package folder and rename it to to something like package_code so as to avoid a namespace collision. If I enter a Python terminal and try to import package, I get the following error:

ImportError: /home/user/code/package.cpython-39-x86_64-linux-gnu.so: undefined symbol: _PyObjectDict_SetItem

I can’t find much online around the error I’m having, except for something else pertaining to scikit-learn, which is a dependency of package. I also see that _PyObjectDict_SetItem is mentioned in the Nuitka Roadmap.

My first question is: must I use --follow-imports in order to Nuitka-compile all dependencies, or is it possible to Nuitka-compile only my package, which would then make use of other .py dependencies that it might import?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Nov 10, 2021

The solution for the issue is on develop and will be part of the next release.

0reactions
kayhayencommented, Dec 3, 2021

This is part of the 0.6.18 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting — Anaconda documentation
Collecting package metadata (current_repodata.json): failed ... One option is to download and install the smaller Miniconda (under 60MB) and then use the ...
Read more >
Module not found error in VS code despite the fact that I ...
To Solve VSCode ModuleNotFoundError: No module named X Error Make sure you are running from the package folder (not from package/module ) if ......
Read more >
Making a Python Package
Packages. A “package” is essentially a module, except it can have other modules (and indeed other packages) inside it. The __init__.py can be...
Read more >
Installing Python Modules (Legacy version) — Python 3.11.1 ...
If all these things are true, then you already know how to build and install the modules you've just downloaded: Run the command...
Read more >
How to Setup Your Python Environment for Machine Learning ...
You may need to install some packages and confirm the updates. ... gamer\Anaconda3\lib\site-packages\theano\compile\mode.py”, line 10, in
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