Running flask in Python

Question:

I am new to python and started with learning with spyder IDE.
I was trying to run flask application in spyder but looks like I am making some mistakes while running it. Can anyone help me ?

enter image description here

If you see the above image… When I run app.py, i get error message as "No module names flask". But when I see flask version , i get 2.2.2 (meaning flask is already there). Then why I am getting this error?

I already installed flask in terminal

enter image description here

Asked By: user11740857

||

Answers:

I guess you have several versions of Python

First try this :

Comment lines 9 and 10

Create a new terminal in the path of the file and type this:

flask run

If this does not work, you can create a virtual environment in Python and install Flask in it

Answered By: FatemeZamanian

The !flask command goes over your shell and calls flask.exe inside AnacondaScripts this should work for every environment(?)

import flask goes over your current environment in which flask is not installed according to the error.

Did you create a new environment and run spyder from there?
If you open anaconda console -> python -> import flask
What happens then?

Rare chance that this is an error with your PATH but probably just the missing installation for the environment.

Answered By: Daraan
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.