I have the latest PyCharm CE and am using it with virtualenv
. I have defined the interpreter as the interpreter in the virtualenv
. The Project Inte
I was also facing the same issue (includes are still not being found) even after Nathaniel Ford and dieend's correct suggestion. Make sure that your run/debug configuration as correct python interpreter selected:
I noticed that every time I open a different project it still has the venv from the project I was previously working on.
What I do is:
ctrl-alt-s (to go into preferences), then Project Interpreter/settings (gear icon), show all, then remove all the venv environments that aren't your current project (use the - sign). Restart, and you should be good to go.
Open up Preferences -> Project -> Project Interpreter
, do you see the module there?
If yes, you might have another file somewhere in your project have the same name as flask.ext.login
, this prevents pycharm from locating the actual module.
If no, you can click on the ...
beside your interpreter and select more...
, select your interpreter and at the bottom (beside the filter), click the Show paths for the selected interpreter
, you can add the path of your module there.
The problem may lay in PyCharm picking up faulty 'Interpreter Paths' for your virtual environment. Go here:
PyCharm (menu) -> Preferences (Menu option)
-> Project: <name> (Dropdown)
-> Project Interpreter (Menu option)
-> 'Settings' button (Looks like a gear)
-> More (Menu option)
-> Select your virtualenv interpreter
-> Click 'Show paths for interpreter' button (on bottom of list window)
Now that you're in this (admittedly tortuously found) location, you should see paths being used by this interpreter. If my theory is correct, these are pointing to global system locations. To add the virtual environment paths, you should click the +
button and add corresponding paths that exist inside your virtual environment. Once you're done with this, it's a good idea to select the global system paths and click -
to remove them. Click apply, and go to File -> Invalidate caches / Restart
to reload PyCharm.
This should get your interpreter to be pointed to the correct location for the libraries you've installed into your virtualenv, and you should no longer be getting the import error. Note that even with this fix you will not see your libraries under the Project Interpreter
, but they should be being loaded.
My two cents on this topic as I struggled myself with it recently. Nathaniel Ford's answer is the good one except that this part:
-> Select your virtualenv interpreter
was unclear to me.
I tried several times with
~/.virtualenvs/python-audition-2.9/bin/python
whereas it only worked with
~/.virtualenvs/python-audition-2.9/local/bin/python
Notice the .../local/...
in the latter path? It was really important in my case. And don't forget to File -> Invalidate caches / Restart
to reload PyCharm.
Goto /venv/bin/ and check all activate scripts. You venv path might be wrong.