Home > Mobile >  ModuleNotFoundError when running child package module
ModuleNotFoundError when running child package module

Time:09-03

proj
|
|
|---flaskr
|    |---__init__.py
|
|    |---scripts
|        |---__init__.py
|        |---build_database.py

My flaskr.__init__.py looks like this

import os
import connexion
from flask_cors import CORS


def create_app(test_config=None):
...

When I run build_database.py in the project root folder with the following command

python3 -m flaskr.scripts.build_database

I get the following error

ModuleNotFoundError: No module named 'connexion'

But I have installed connexion using pip and when I run the whole Flask app with flask run it works fine.

Any ideas why I'm getting the ModuleNotFoundError when running the build_database module?

CodePudding user response:

I would run python3 -mconnexion to make sure python3 has access to the module. I suspect flask and pip are running under a different python interpreter then python3.

  • Related