Kwsswart
Kwsswart

Reputation: 541

How can I get flask to run correctly in VS Code?

The Problem:

I have moved over to Visual Studio Code in order to try to learn to program in a real IDE, however I am low in experience.

What I have done:

I have done the following to get it up and running:

Installed:
  VS Code,
  Python, 
  Postgres,
  PGAdmin
  pip

I have:

The Error Message

However whenever I run flask run I get the following error message in the CMD

"flask no se reconoce como un comando interno o externo programa o archivo por lotes ejecutable" 

In visual studio I get this error message when I run 'flask run':

flask : El término 'flask' no se reconoce como nombre de un cmdlet, función, archivo de script o programa ejecutable. Compruebe si
escribió correctamente el nombre o, si incluyó una ruta de acceso, compruebe que dicha ruta es correcta e inténtelo de nuevo.
En línea: 1 Carácter: 1
+ flask run
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (flask:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

The Question:

I am using Windows 10. How can I get this working?

Upvotes: 2

Views: 24862

Answers (2)

Sanket Singh
Sanket Singh

Reputation: 1366

Imp: In Windows 10: Visual studio's integrated terminal is PowerShell. Whereas it was cmd.exe for earlier.

Do:

  1. On Command Prompt:

    set FLASK_APP=application.py

  2. On powershell

    $env:FLASK_APP = "application.py"

python -m flask run . Try to use this and if this will not work you have to install flask using pip install flask or pip3 install flask in your local .

then use flask run

For more info check: https://pypi.org/project/Flask/

Upvotes: 4

Dwij Mehta
Dwij Mehta

Reputation: 98

If you have not installed flask using $ pip install then the problem could be that flask is not added as a PATH environment variable.

Try adding flask to your env variables. If this doesn't work then try running $ python -m flask run as a temporary workaround.

Upvotes: 0

Related Questions