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.

Numpy >=1.22.0 RuntimeError

See original GitHub issue

Hi 👋 There appears to be an issue when using the newer Numpy >= 1.22.0 (current release is 1.22.1). It compiles without issue but gives the following error when trying to run the compiled standalone:

Traceback (most recent call last):
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy_test.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy/__init__.py", line 144, in <module numpy>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy/core/__init__.py", line 23, in <module numpy.core>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy/core/multiarray.py", line 80, in <module numpy.core.multiarray>
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy/core/overrides.py", line 201, in decorator
  File "/home/theguy/projects/test_nuitka/numpy_test.dist/numpy/core/overrides.py", line 183, in decorator
RuntimeError: __code__ is not writable in Nuitka

Issue tested with Nuitka 0.6.18.6, 0.6.19.1 and develop branch. If one holds the numpy version back to 1.21.5, there’s no problem.

0.6.19.1
Commercial: None
Python: 3.9.7 (default, Sep 10 2021, 14:59:43) 
Flavor: Debian Python
Executable: /home/theguy/.cache/pypoetry/virtualenvs/test-nuitka-Z7Y54p4h-py3.9/bin/python
OS: Linux
Arch: x86_64
Distribution: Pop 21.10

Installed through poetry (virtualenv)

Nuitka @ file:///home/theguy/.cache/pypoetry/artifacts/0e/82/a6/3eda349f3337b0fbbda8ecb9a47f50a9ee2e7095fa023a188751046956/Nuitka-0.6.19.1.tar.gz numpy @ file:///home/theguy/.cache/pypoetry/artifacts/df/02/c1/3940f115306d04c79d2a84ed299e313221e70a193e47f967dc53ac0986/numpy-1.22.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

SSCCE: numpy_test.py

# nuitka-project: --standalone
# nuitka-project: --plugin-enable=numpy
# nuitka-project: --static-libpython=no

import numpy as np

arr = np.array([[1, 2, 3], [4, 2, 5]])
print("Shape of array: ", arr.shape)

python -m nuitka numpy_test.py

./numpy_test.dist/numpy_test

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kayhayencommented, Jan 16, 2022

It seems there was also a macOS issue caused by build system changes, also on factory and will be in the hotfix too, which I had to delay because of that.

1reaction
kayhayencommented, Jan 15, 2022

I will look into this tomorrow, but you try to enable the anti-bloat plugin, that might help, as it removes stuff in that area.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RuntimeError when importing numpy 1.19.4 · Issue #17726
I am using Python 3.9 64-bit on Windows 10. Reproducing code example: import numpy as np # raises a RuntimeError Error message: $...
Read more >
Cannot install latest version of Numpy (1.22.3) - Stack Overflow
I am trying to install the latest version of numpy, the 1.22.3, but it looks like pip is not able to find this...
Read more >
NumPy 1.22.1 Release Notes
The NumPy 1.22.1 is a maintenance release that fixes bugs discovered after the 1.22.0 release. Notable fixes are: Fix f2PY docstring problems (SciPy)....
Read more >
Numpy is not available error - audio - PyTorch Forums
... X_batch = torch.from_numpy(X_batch).to(self.device) RuntimeError: Numpy is not available. why is this error happening in PyTorch?
Read more >
Numpy install with reticulate fail sanity check - General
RuntimeError : The current Numpy installation ('/**my_home**/projects/22_06_Numpy_reprex/penv/lib/python3.8/site-packages/numpy/__init__.py') ...
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