user3595626
user3595626

Reputation: 1

Getting an error when importing an installed module

C:\Python38\python.exe 
C:/Users/black/Desktop/matplotlib.py
Traceback (most recent call last):
  File "C:/Users/black/Desktop/matplotlib.py", line 1, in <module>
    import matplotlib
  File "C:\Users\black\Desktop\matplotlib.py", line 2, in <module>
    matplotlib.__version__
AttributeError: partially initialized module 'matplotlib' has no attribute '__version__' (most likely due to a circular import)

The code that I'm running is :

import matplotlib
matplotlib.__version__

Shows installed module

And it always generates a file on my Desktop in a folder ' pyCache '

Upvotes: 0

Views: 823

Answers (1)

Hoxha Alban
Hoxha Alban

Reputation: 1137

Because your code is trying to import itself (base case of circular import), since you've named it "matplotlib.py".

Simply rename your file and it will work (probably)

Upvotes: 1

Related Questions