I have configured a Flask project in Eclipse Neon (with Eclipse PyDev plugin).
When running a Flask script in Eclipse, I got an error in the Eclipse console:
{Traceback (most recent call last):
File "/home/pawel/workspace/occ/app/__init__.py", line 1, in <module>
from flask import Flask
ImportError: No module named 'flask'}
In Eclipse, I have set python interpreter to my venv
dir (python3.5 with Flask installed on it, screen below):
When I start my Flask project from cmd
(in venv), it runs properly (example below):
pawel@ubu-dev:~/workspace/occ$ source venv-python3.5-flask/bin/activate
(venv) pawel@ubu-dev:~/workspace/occ$ python3.5 run.py
config set to config.Config
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Restarting with stat
config set to config.Config
Debugger is active!
Debugger pin code: 218-632-435
Any ideas what kind of "special" config in Eclipse should I do to make Flask module visible for eclipse pydev?
In venv
in cmd, I can see that Flask module is installed via pip3 like here:
pawel@ubu-dev:~/workspace/occ$ source venv-python3.5-flask/bin/activate
(venv) pawel@ubu-dev:~/workspace/occ$ pip3 list
- Flask (0.11.1)
- Flask-Babel (0.11.1)
- Flask-Bootstrap (3.3.7.0)
- Flask-Login (0.4.0)
- Flask-Mail (0.9.1)
- Flask-OpenID (1.2.5)
- Flask-SQLAlchemy (2.1)
- Flask-WhooshAlchemy (0.56)
- Flask-WTF (0.13.1) etc...
My guess is that there are missing folders from the standard library in your system libs.
Do the following: in your shell, activate the virtual env and then run:
Then, add the missing folders to the interpreter (any folder which is not a part of your project should be there).
You can also try to remove and re-add the interpreter as I think the folders were shown to you but were initially unchecked because PyDev thought they were part of your project, not from the interpreter (so, after adding, please go through the list of folders and make sure the proper ones are left checked).