2

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:

  • Changed the path of python following a tutorial.
  • Installed flask, flask-session and SQLAlchemy.
  • Used the following "set FLASK_APP=application.py" and "set FLASK_DEBUG=1" and also "set DATABASE_URL= url of database" both in cmd and in visual studio terminal

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?

1
  • It might be helpful to know the english version of this error, if possible. Commented Jun 22, 2020 at 18:38

2 Answers 2

4

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/

Sign up to request clarification or add additional context in comments.

11 Comments

should i do this in cmd or visual
Visual's terminal you can use. To open it press Ctrl+` .
this doesnt work unfortunately getting the same response
python -m flask run . Try to use this and if this will not work you have to install flask using pip install flask in your local . If you have pip3 installed, use pip3 install flask.
Sofar this would be working how could i get it so that the database url is set in with similar commands would $DATABASE_URL = "url to database" work?
|
0

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.

2 Comments

I have not setup an environment because didnt think needed to... I just have python installed and used pip to install libraries directly?
yes after following the above to set the flask app to application.py all i have now is its saying database_url not set

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.