问题
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:
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?
回答1:
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
来源:https://stackoverflow.com/questions/61906604/pycharm-reporting-no-module-found-but-when-i-go-to-look-for-it-then-its-there-i