Alan2
Alan2

Reputation: 24552

PyCharm reporting no module found but when I go to look for it then it's there in the correct directory

My application is running in PyCharm and giving me an error saying:

File "/Users/Alan/PycharmProjects/anki4/qt/aqt/__init__.py", line 17, in <module>
import aqt.buildinfo

ModuleNotFoundError: No module named 'aqt.buildinfo'

When I hover over that line it shows this:

enter image description here

But I can go to the terminal and confirm it's there:

% cd /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aqt/
% ls build*

buildinfo.py    
% cat buildinfo.py
buildhash='70784154'
version='2.1.26' 

Does anyone have any idea what's wrong?

Upvotes: 0

Views: 164

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 113930

its looking at this /Users/Alan/PycharmProjects/anki4/qt/aqt/ folder ...

but that doesnt exist in that folder ...

apparently it is found here /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aqt/ ... but that doesnt matter because /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aqt/ is being shadowed by /Users/Alan/PycharmProjects/anki4/qt/aqt/

consider the following

print(sum([1,2,3,4,5])) # 15
sum = 15
print(sum([1,2,3,4,5])) # Error... because you have shadowed the builtin sum

the same problem exists for modules

if i have a file named os.py ... and i open a python terminal in that folder and say import os i will import my os.py not the system os module that i probably am actually trying to import

Upvotes: 1

Related Questions