AttributeError: module 'numpy.random' has no attribute 'BitGenerator' in python 3.8.10
Asked Answered
D

2

9

I'm trying to import the xarray module into python 3.8.10 but I get this error:

AttributeError: module 'numpy.random' has no attribute 'BitGenerator'

In order to allow you to reproduce the error: First of all, I created a new environment with conda and by importing at the same time the modules I need (to avoid the problems of incompatible dependencies) :

conda create -n Myenv Python=3.8 matplotlib numpy time xarray netCDF4 termcolor

Then, I try to import in ipython3 all modules I need to run my code:

import matplotlib as mpl
mpl.use('agg')
import numpy as np
import os
import time
import glob
import sys
from datetime import datetime,date,timedelta
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import matplotlib.colors as colors
# from operator import itemgetter
from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap, shiftgrid
from termcolor import colored
import xarray as xr

and, at this moment, I get the error...

I searched the documentation to see if the BitGenerator Attribute exists in my version of numpy (1.22.3), and it does. So I don't understand why this error occurs.

Someone can help me to understand please ?

Thank u !

If you want more informations about my environnement, I can provide.

Dermatoplasty answered 8/3, 2022 at 17:27 Comment(0)
H
9

I solved mine with pip install --upgrade numpy

Hungary answered 13/3, 2022 at 20:27 Comment(4)
This almost works. pip should not be called with sudo, and the arguments are a bit off. pip install --upgrade numpy does the trick.Diglot
@FrankKusters I'd recommend changing your comment to an answer. It fixed my problem.Utopia
I edited @Jianer's answer to fix the issue.Diglot
It’s still not working for me.Pavlov
K
0

firstly, I thought this error is in version of numpy, so I tried installing many versions, such as 1.18, 1.22, then back to 1.24, blablo

but actually, it is in version of python which is 3.8

there would be no error with python 3.10

Kaylil answered 7/9 at 5:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.