Intellij / Python / Flask / virtualenv - using the interactive debugger

I installed the Python plugin and created a virtualenv for an existing Flask project. I added a Python SDK with this virtualenv.

Intellij recognized that the dependencies in the requirements.txt were missing so I installed them.

Moreoever, I checked if I have all dependencies in my virtualenv -> OK.

When I try to run a flask instance with the interactive debugger - Intellij does not find certain dependencies - maybe it is missing

to activate the virtualenv even though it is specified in the SDK of the module

 

FLASK_APP = oqp_backend
FLASK_ENV = development
FLASK_DEBUG = 1

In folder /Users/pkonrad/workspace/myproject

/Users/pkonrad/workspace/myproject/venv/bin/python "/Users/pkonrad/Library/Application Support/IntelliJIdea2019.3/python/helpers/pydev/pydevd.py" --module --multiproc --qt-support=auto --client 127.0.0.1 --port 59370 --file flask run --port 8000

pydev debugger: process 21088 is connecting

Connected to pydev debugger (build 193.6494.35)
* Serving Flask app "myproject" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
* Restarting with stat
pydev debugger: process 21092 is connecting

 

However,

 

127.0.0.1 - - [06/Mar/2020 18:01:45] "OPTIONS /graphql HTTP/1.1" 500 -
Traceback (most recent call last):
File "/Users/pkonrad/workspace/myproject/backend/__init__.py", line 8, in <module>
from oqp_backend.app import create_app
File "/Users/pkonrad/workspace/myproject/myproject/app.py", line 30, in <module>
from oqp_backend.graphql import schema
File "/Users/pkonrad/workspace/myproject/backend/graphql/schema.py", line 1, in <module>
import graphene
File "/Users/pkonrad/workspace/myproject/venv/lib/python3.7/site-packages/graphene/__init__.py", line 3, in <module>
from .types import (
File "/Users/pkonrad/workspace/myproject/venv/lib/python3.7/site-packages/graphene/types/__init__.py", line 2, in <module>
from graphql import ResolveInfo
ImportError: cannot import name 'ResolveInfo' from 'graphql' (/Users/pkonrad/workspace/myproject/backend/graphql/__init__.py)

 

In PyCharm all this functionality worked without further configuration and I don't really know what I should do now with Intellij.

Before I checked if graphene was actually installed:

source venv/bin/activate
➜  python
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from graphql import ResolveInfo

1 comment
Comment actions Permalink

Does the issue reproduce when you just Run it instead of Debug?
If yes, copy the executed by IDE command (you can see it in the output) and try running it from the system terminal.

0

Please sign in to leave a comment.