Home > Software design >  Errors with matplotlib and numpy
Errors with matplotlib and numpy

Time:02-02

i am trying to learn using matplotlib and to do so i installed Anaconda3 and VSCode. With anaconda3 all the required libraries are installed, but when i try running a simple code i get a bunch of errors.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

fruits = \['apple', 'blueberry', 'cherry', 'orange'\]
counts = \[40, 100, 30, 55\]
bar_labels = \['red', 'blue', '\_red', 'orange'\]
bar_colors = \['tab:red', 'tab:blue', 'tab:red', 'tab:orange'\]

ax.bar(fruits, counts, label=bar_labels, color=bar_colors)

ax.set_ylabel('fruit supply')
ax.set_title('Fruit supply by kind and color')
ax.legend(title='Fruit color')

plt.show()

this is a simple code i found online and i tried running it to see if everything worked correctly but i get this:

Traceback (most recent call last):
  File "c:\Users\ahmed\Desktop\saved\mat1.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\ahmed\anaconda3\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
    import numpy
  File "C:\Users\ahmed\anaconda3\lib\site-packages\numpy\__init__.py", line 150, in <module>
    from . import core
  File "C:\Users\ahmed\anaconda3\lib\site-packages\numpy\core\__init__.py", line 70, in <module>
    from . import numerictypes as nt
  File "C:\Users\ahmed\anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 596, in <module>
    _register_types()
  File "C:\Users\ahmed\anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 591, in _register_types
    numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'

and the errors are: enter image description here

  • Related