0

I had a few imports I was using for my project. Some of these included packages I downloaded using pip like

import MySQLdb

While others were modules from within my project like

sys.path.append(os.path.join(os.path.dirname(__file__), "../")) .   
from util.myFile import get_mysql_connection, execute_query, 

These were all working and I was able to run my application on PyCharm. I closed PyCharm and opened it back up to find most of these imports "could not be found". Any help regarding this will be much appreciated. Thanks

Update:

I'm able to run the file from terminal (iTerm) without errors. However, the file still shows red error marks by the imports. Seems like PyCharm isn't recognizing some sort of path

Ash_s94
  • 787
  • 6
  • 19
  • `sys.path.append(os.path.join(os.path.dirname(__file__), "../"))` although this doesn't answer your question, this is *really not how you should handle this*. – juanpa.arrivillaga Aug 27 '19 at 19:18
  • How long had it been since you last closed PyCharm? Is it possible you changed some path setting within PyCharm and then didn't save it? – John Gordon Aug 27 '19 at 19:49

2 Answers2

0

Check the traceback for what version of python is being called.

There could be a mismatch between the version you've imported modules with and the version that runs by default.

Anthony R
  • 2,739
  • 1
  • 12
  • 11
0

Double check what is being used as your project interpreter. This can change the available packages to your current project.

Found in PyCharm by going to Settings -> Project:<'Your-Project'> -> Project Interpreter

Also, did you install MySQLdb in this way? MySQLdb - ModuleNotFoundError

BeRT2me
  • 12,699
  • 2
  • 13
  • 31