Nuitka: Numpy 1.18: AttributeError: module 'numpy.random._bit_generator' has no attribute 'BitGenerator''

Created on 29 Mar 2020  路  7Comments  路  Source: Nuitka/Nuitka

This is stable version of the code, I believe develop is already better, which you were recommended to try out.

_Originally posted by @kayhayen in https://github.com/Nuitka/Nuitka/issues/658#issuecomment-605414283_

bug

Most helpful comment

It's working for me with numpy=1.17

All 7 comments

Thank you @kayhayen for your reply.

I indeed had no problem compiling with the develop branch ... but the exe does not work.
Here is the error:

Traceback (most recent call last):
File "C:\PROGRA1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\IHM_SLAM_S.py", line 22, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "C:\PROGRA1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\SRC\sDon.py", line 14, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "C:\PROGRA1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\SRC\sRunClass.py", line 11, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "C:\PROGRA1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\numpy_init.py", line 152, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in load_unlocked
File "C:\PROGRA~1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\numpy\random_init.py", line 181, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "C:\PROGRA~1\ECL_AIR\IHM_SLAM_S_PY3\IHM_SLAM_S.dist\numpy\random_pickle.py", line 1, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "_bit_generator.pxd", line 14, in init numpy.random.mtrand
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "_bit_generator.pyx", line 1, in init numpy.random._bit_generator
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "_bit_generator.pxd", line 14, in init numpy.random._common
AttributeError: module 'numpy.random._bit_generator' has no attribute 'BitGenerator'

This looks like it might be a kind of circular dependency issue. The module loading maybe doesn't properly integrate from Cython that is used there in numpy. I will need to look at that myself. Can you make sure to provide a minimal reproducer?

Please find attached a minimal reproducer.
bug_reproducer.zip

It seems that the bug appears when the numpy module is imported ...

Here is the result of python -m nuitka --version:

0.6.8rc5
Python: 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 22:22:21) [MSC v.1916 64 bit (AMD64)]
Executable: D:\Programme\Anaconda3\envs\Exe\python.exe
OS: Windows
Arch: x86_64

Hi, any news or workaround regarding this?

It's working for me with numpy=1.17

I meet the same problem on windows, and you can reproduce it with code shown next:

# filename: compile_test.py
import numpy as np
from pprint import pprint

pprint(np.array([1, 2, 3, 4]))

and compile python code with:

(SHARED_VENV) D:\PY_PROJ\data-polisher>nuitka --standalone  --follow-imports --plugin-enable=numpy compile_test.py
Nuitka-Plugins:INFO: numpy: Copied 1 file from 'numpy' installation.

finally:

(SHARED_VENV) D:\PY_PROJ\data-polisher\compile_test.dist>compile_test.exe
Traceback (most recent call last):
  File "D:\PY_PROJ\data-polisher\compile_test.dist\compile_test.py", line 2, 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 "D:\PY_PROJ\data-polisher\compile_test.dist\numpy\__init__.py", line 152, in <module numpy>
  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 "D:\PY_PROJ\data-polisher\compile_test.dist\numpy\random\__init__.py", line 181, in <module numpy.random>
  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 "D:\PY_PROJ\data-polisher\compile_test.dist\numpy\random\_pickle.py", line 1, in <module numpy.random._pickle>
  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 "_bit_generator.pxd", line 14, in init numpy.random.mtrand
  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 "_bit_generator.pyx", line 1, in init numpy.random._bit_generator
  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 "_bit_generator.pxd", line 14, in init numpy.random._common
AttributeError: module 'numpy.random._bit_generator' has no attribute 'BitGenerator'

my nuitka version is 0.6.8.3

(SHARED_VENV) D:\PY_PROJ\data-polisher>nuitka --version
0.6.8.3
Python: 3.7.6rc1 (tags/v3.7.6rc1:bd18254b91, Dec 11 2019, 20:31:07) [MSC v.1916 64 bit (AMD64)]
Executable: D:\PY_PROJ\SHARED_VENV\Scripts\python.exe
OS: Windows
Arch: x86_64

This is the last release 0.6.9 already for a while.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ohlr picture ohlr  路  5Comments

Goczilla picture Goczilla  路  4Comments

EnzoRondo picture EnzoRondo  路  10Comments

Slyfoxy picture Slyfoxy  路  3Comments

redstoneleo picture redstoneleo  路  4Comments