Search code examples
python-3.xvisual-studio-codeflask-scriptpipenv-install

Module installed but Python cannot find it


I am using VS Code running Python 3.9 I have set up a virtual environment using pipenv shell and I installed flask-script as displayed here in my pipfile:

   [packages]
   flask = "*"
   sqlalchemy = "*"
   flask-sqlalchemy = "*"
   flask-script = "*"
   flask-migrate = "*"

Still the import at the top of the Python file shows yellow underline and: Import "flask_script" could not be resolved Pylance report MissingImports

and if you try and run it it says: ModuleNotFoundError: No module named 'flask_script'

So how does it work please? This happens with other modules now and again too. How are you supposed to install a module?

Any help is appreciated


Solution

  • Maybe you need to select the correct python interpreter for the dependencies to be found.

    enter image description here

    Make sure it's the one for your virtual environment (You should see the parentheses as here in the screenshot, you can click there and select the correct one).