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.

No module named 'math' (on self compiled Python '3.10')

See original GitHub issue

Hello,

from Nuitka (User Manual) I have used a sample just to give it a try. The problem is that I get an error ModuleNotFoundError: No module named ‘math’. I don’t know why Nuitka has issues with builtin random or math modules.

nuitka --standalone hello.py --run

(venv) [root@cent01 ldif-mixer]# python -m nuitka --standalone hello.py --run Nuitka-Options:INFO: Used command line options: --standalone hello.py --run Nuitka-Options:INFO: Detected static libpython to exist, consider ‘–static-libpython=yes’ for better performance, but errors may happen. Nuitka:INFO: Starting Python compilation with Nuitka ‘1.0.6’ on Python ‘3.10’ commercial grade ‘not installed’. Nuitka-Plugins:INFO: multiprocessing: Injecting pre-module load code for module ‘multiprocessing’: Nuitka-Plugins:INFO: multiprocessing: Monkey patching “multiprocessing” load environment. Nuitka-Plugins:INFO: multiprocessing: Injecting post-module load code for module ‘multiprocessing’: Nuitka-Plugins:INFO: multiprocessing: Monkey patching “multiprocessing” for compiled methods. 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: gcc (gcc). Nuitka-Scons:INFO: Backend linking program with 13 files (no progress information available). Nuitka-Scons:WARNING: You are not using ccache. Nuitka:INFO: Keeping build directory ‘hello.build’. Nuitka:INFO: Successfully created ‘hello.dist/hello’. Nuitka:INFO: Launching ‘hello.dist/hello’ Traceback (most recent call last): File “/usr/local/netzwert/ldif-mixer/hello.dist/hello.py”, line 11, in <module> File “/usr/local/netzwert/ldif-mixer/hello.dist/random.py”, line 49, in <module> ModuleNotFoundError: No module named ‘math’

hello.py

import random

def talk(message):
    return "Talk " + message

def main():
    print(talk("Hello World"))

if __name__ == "__main__":
    main()

Best Regards, Kresimir

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Sep 16, 2022

That is very helpful. I believe your libpython3.10 might be miscompiled. At leaast I am using --enable-shared or older systems, albeit all Debian, and have it working. It can be avoided by using --static-libpython=yes in which case it may still not work, and of course will even be better for performance.

0reactions
kayhayencommented, Oct 9, 2022

Closing for lack of feedback

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python error "ImportError: No module named" - Stack Overflow
After you've set your PYTHONPATH in the step above, run your module from your current directory (the toolkit directory). Python should now find...
Read more >
Installing Python Modules (Legacy version) — Python 3.11.1 ...
The up to date module installation documentation. ... First, the distribution's name and version number will be featured prominently in the name of...
Read more >
What's New In Python 3.8 — Python 3.11.1 documentation
Editor, Raymond Hettinger,. This article explains the new features in Python 3.8, compared to 3.7. Python 3.8 was released on October 14, 2019....
Read more >
What's New In Python 3.11 — Python 3.11.1 documentation
Release, 3.11.1,, Date, December 20, 2022,, Editor, Pablo Galindo Salgado,. This article explains the new features in Python 3.11, compared to 3.10.
Read more >
What's New In Python 3.9 — Python 3.11.1 documentation
In Python 3.10, the old parser will be deleted and so will all ... Starting with Python 3.9.5 the ipaddress module no longer...
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