0

I was getting started with MatPlotLib, and I was trying to print out the version number.

Here is my code:

import matplotlib
print(matplotlib.__version_)

But, I get an error when I run it:

Traceback (most recent call last):
  File "c:/Users/Atharv 2020/Pyfiles/matplotlib.py", line 1, in <module>
    import matplotlib
  File "c:\Users\Atharv 2020\Pyfiles\matplotlib.py", line 2, in <module>
    print(matplotlib.__version_)
AttributeError: partially initialized module 'matplotlib' has no attribute '__version_' (most likely due to a circular import)

Can you help me?

Atharv Nadkarni
  • 13
  • 1
  • 10
  • 1
    Does this answer your question? [AttributeError: partially initialized module 'turtle' has no attribute 'Turtle' (most likely due to a circular import)](https://stackoverflow.com/questions/60480328/attributeerror-partially-initialized-module-turtle-has-no-attribute-turtle) – dm2 Jun 05 '21 at 08:18
  • @dm2 Yes! I have posted your answer as a comment. – Atharv Nadkarni Jun 05 '21 at 08:32

1 Answers1

1

According to @dm2's comment above, the mistake was writing the code in a file called matplotlib.py. When I import matplotlib, I actually import matplotlib.py (the file) rather than matplotlib (the library). So renaming the file will fix the problem.

I also realized that that there was only 1 underscore after "version".

Thank you, @dm2!

Atharv Nadkarni
  • 13
  • 1
  • 10