Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 472
Lepkeo Avatar asked May 22 '26 07:05

Lepkeo


1 Answers

I solved mine with pip install --upgrade numpy

like image 60
Jianer Avatar answered May 24 '26 20:05

Jianer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!