I'm developing an API running on a Connexion-Flask app using Visual Studio Code. When started with flask run
it works fine.
But when I'm trying to debug this app using the VS Code debugger I get the following error message:
Traceback (most recent call last):
File "d:\QT_Code\itk-demo-configdb\source\app.py", line 3, in <module>
from connexion import FlaskApp
ModuleNotFoundError: No module named 'connexion'
The launch.json that I use for debugging is the following (which I found in this thread which asks a very similar question (but I can't make a comment there):
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Connexion",
"type": "python",
"request": "launch",
"module": "connexion",
"env": {
"FLASK_APP": "app.py",
"FLASK_ENV": "development",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"./db_api",
"--port",
"8080"
],
"jinja": true
}
]
}
My app.py Is the following:
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from connexion import FlaskApp
from .config import APIConfig
app = FlaskApp(__name__, specification_dir='db_api/', options={"swagger_ui": True})
flask_app = app.app
flask_app.config.from_object(APIConfig)
db = SQLAlchemy(flask_app)
migrate = Migrate(flask_app, db)
app.add_api('db_openapi.yml')
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8080,debug=True)
I'm using the same virtual environment when starting via flask run
and the debugger. So I don't understand why it says that there is no connexion module. Before I implemented Connexion the VS Code debugger worked fine, but now I can't seem to get it working.
Thanks in advance for any help!