Add
Add

Reputation: 627

AttributeError: module 'numpy' has no attribute 'typeDict'

I am trying to install TensorFlow in Python. I am getting the following error message, I tried uninstalling NumPy and re-installing NumPy but still getting the same error message. How to resolve this issue?

AttributeError: module 'numpy' has no attribute 'typeDict'

Upvotes: 51

Views: 123739

Answers (13)

kasjhuyvALI7
kasjhuyvALI7

Reputation: 1

I had the same issue. I tried following command and it worked for me:

python -m pip install --upgrade h5py

Found it here.

Upvotes: 0

Victor Vaz
Victor Vaz

Reputation: 1

AttributeError Traceback (most recent call last) Cell In[1], line 7 5 from bs4 import BeautifulSoup # biblioteca para o pré processamento de textos 6 import random # números aleatórios ----> 7 import seaborn as sns # para geração de gráficos 8 import matplotlib.pyplot as pyplot # para gráficos tb

File ~/.local/lib/python3.8/site-packages/seaborn/init.py:5 3 from .utils import * # noqa: F401,F403 4 from .palettes import * # noqa: F401,F403 ----> 5 from .relational import * # noqa: F401,F403 6 from .regression import * # noqa: F401,F403 7 from .categorical import * # noqa: F401,F403

File ~/.local/lib/python3.8/site-packages/seaborn/relational.py:21 13 from .utils import ( 14 adjust_legend_subtitles, 15 _default_color, (...) 18 _scatter_legend_artist, 19 ) 20 from ._compat import groupby_apply_include_groups ---> 21 from ._statistics import EstimateAggregator, WeightedAggregator 22 from .axisgrid import FacetGrid, _facet_docs ... 318 return Tester --> 320 raise AttributeError("module {!r} has no attribute " 321 "{!r}".format(name, attr))

AttributeError: module 'numpy' has no attribute 'typeDict'

I was having this problem and was solved upgrading the scipy package to 1.10.1.

Upvotes: 0

Ursulamursula
Ursulamursula

Reputation: 11

My problem was caused by having an older version of matplotlib. After updating, the error went away:

pip install --upgrade matplotlib

Upvotes: 1

Comsavvy
Comsavvy

Reputation: 770

I did get this exact error while trying to import TensorFlow after installation, but I was able to get around this by upgrading the h5py library. There is no need to degrade the NumPy library, as doing so might cause compatibility issues with other libraries that rely on the upgraded version.

pip install --upgrade h5py

If you check the error message well, you will notice these lines, which state the possible causes:

File “h5py\h5t.pxd”, line 14, in init h5py.conv
File “h5py\h5t.pyx”, line 293, in init h5py.h5t
File "C:\Users\user\anaconda3\envs\myenv\lib\site-packages\numpy_init.py", line 320, in getattr
raise AttributeError("module {!r} has no attribute ")

The solution that does not involve degrading any library is to upgrade the h5py library.

Upvotes: 13

L17
L17

Reputation: 11

I encountered the same error "module 'numpy' has no attribute 'typeDict'" after I installed a new version of Numpy. I was using Scipy for my project, and I found a message related to Scipy when I loaded Scipy, like from scipy.optimize import least_squares in the project.

My solution to this error is to update the mismatch packages that depend on Numpy, which is to run the following:

pip install --upgrade scipy

If you are using other packages that depend on Numpy, please check the error messages and upgrade these packages that may help you to fix this problem. Hope this also works for you.

Best wish.

Upvotes: 1

Asha Choudhary
Asha Choudhary

Reputation: 165

For me pip install numpy==1.21 created more problems,

I resolved it by using '1.22.1' version

Upvotes: 8

Jorge Enriquez
Jorge Enriquez

Reputation: 1

In my case I had a conda environment with Python 3.9.12, numpy was in version 1.25.0.

I solved the problem by updating Keras with:

conda update keras

Keras version was 2.10.0. After gathering the kernel everything worked fine.

Upvotes: 0

Nishant Kumar
Nishant Kumar

Reputation: 41

Spacy still hasnt upgraded to latest numpy versions. I degraded numpy to 1.21 and that worked.

Upvotes: 1

Nuno Brum
Nuno Brum

Reputation: 1

I was able to solve this by upgrading the scipy package to 1.10.

Upvotes: 0

Ignatius Andrew
Ignatius Andrew

Reputation: 8258

You have to degrade your Numpy and pandas version, everything depends on the version that tensorflow supports. No other solution for now

Upvotes: 0

erfunviva
erfunviva

Reputation: 1

I had the same issue. I restarted the kernel and the issue was gone. Try restarting your kernel if you have the correct version of tensorflow and numpy.

Upvotes: 0

Tiago Peres
Tiago Peres

Reputation: 15590

As we can see in NumPy 1.21.0 Release Notes

np.typeDict is a deprecated alias for np.sctypeDict and has been so for over 14 years

(6689502).

A deprecation warning will now be issued whenever getting np.typeDict.

(gh-17586)

This means you are using a NumPy version that removed the deprecated ways AND the library you are using wasn't updated to match that version (uses something like np.typeDict instead of np.sctypeDict).

You have at least three options now

  1. Report the issue and wait until it gets fixed by TensorFlow.
  2. Use an older version of numpy (one before it started to issue the deprecation warning) and wait for it to be fixed.
  3. Change np.typeDict to np.sctypeDict wherever is being used.

Upvotes: 11

Rboreal_Frippery
Rboreal_Frippery

Reputation: 2318

I was trying to use the package pyensembl and ran into this same issue. I was able to work around it for now with

pip install numpy==1.21

Which should suffice until some of these less active packages are able to update to the new API.

Upvotes: 65

Related Questions