Here's corner case: if you moved your project folder to some other place in your file-system, then some caching of PyCharm on your project folder, might be forcing and old interpreter path behind the scenes, even though you defined a new one. And of course, you'll see no packages from your Virtualenv, for the interpreter object itself, was not recognized by PyCharm.
If that's the case, there are two options:
- erase the folder
.idea from your project's root folder, close PyCharm and open it up again, in order to set up your Python interpreter. - invalidate PyCharm cache:
File -> Invalidate Caches...
For debugging PyCharm logs: Help -> Show Log in Files...
On Ubuntu, generally, the main PyCharm log is available on the following path:
~/.cache/JetBrains/PyCharmCE2023.1/log/idea.log: the directory PyCharmCE2023.1 is named based on your PyCharm installation date, so it might be a different directory on your file-system.
You can use PyCharm while visualizing the log file and the possible errors related with the interpreter setup, in order to figure out the issue:
$ tail -f .cache/JetBrains/PyCharmCE2023.1/log/idea.log 2023-06-01 20:37:35,376 [22188086] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:41:17,038 [22409748] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:42:02,206 [22454916] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:42:23,752 [22476462] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:42:32,623 [22485333] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:49:01,659 [22874369] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:49:09,130 [22881840] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files 2023-06-01 20:49:11,019 [22883729] INFO - #c.i.i.a.RevealFileAction - Timed out 2023-06-01 20:49:11,019 [22883729] INFO - #c.i.i.a.RevealFileAction - Nautilus-Share-Message: 20:49:01.414: Called "net usershare info" but it failed: Failed to execute child process “net” (No such file or directory)
File -> Invalidate Cachesand restart PyCharm. You might have to wait some minutes for it to rebuild the caches