Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running flask run produces error.
#1
Hi,

I'm following a tutorial on Flask development on Windows 10.
I installed virtual environment and install flask.

Then I exported this:
FLASK_ENV=development
FLASK_APP=main.py

Then while in virtualenv I typed:
flask run

(env) J:\Web Projects\enrollment>flask run
* Serving Flask app "main.py" (lazy loading)
* Environment: development
* Debug mode: on
* Restarting with stat
j:\envs\env\scripts\python.exe: No module named J:\Envs\env\Scripts\flask

However if I do this:
python -m flask run
everything works.

I've done a lot of searching with no success.
What am I doing wrong?

Python: 3.7.3
Flask: 1.1.1

Thanks in advance for any help.
Reply
#2
(Oct-04-2019, 10:06 AM)Charles1 Wrote: Then I exported this:
You most use set on Windows,and venv is build into Python no install.
Example.
C:\code
λ python -m venv flask_env

C:\code
λ cd flask_env\

C:\code\flask_env
λ C:\code\flask_env\Scripts\activate

(flask_env) C:\code\flask_env
λ set FLASK_APP=app.py

(flask_env) C:\code\flask_env
λ flask run
 * Serving Flask app "app.py"
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [05/Oct/2019 00:16:57] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [05/Oct/2019 00:16:57] "GET /favicon.ico HTTP/1.1" 404 -
Not fan of setting environment variable like this.
python-dotenv fix this as it bring into project and not use OS path.
From Flask 1.0 --> there is build in support for python-dotenv.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Server Error with parse_args() using Flask NoNameoN 0 1,091 Jul-30-2022, 09:42 AM
Last Post: NoNameoN
Question [Solved] Running Gunicorn with flask.... SpongeB0B 1 1,610 Jun-27-2022, 03:09 PM
Last Post: SpongeB0B
  [split] flask 500 internal server error DarthTensor 3 4,016 Nov-11-2021, 06:10 AM
Last Post: DarthTensor
Question running Flask with waitress having web traffic log... SpongeB0B 2 5,878 May-06-2021, 07:07 AM
Last Post: SpongeB0B
  Error updating one to many relationship in Flask/ SQLAlchemy atindra 0 3,334 Apr-15-2021, 10:29 PM
Last Post: atindra
  TemplateNotFound error with flask Veztar 4 18,798 Aug-28-2020, 07:02 AM
Last Post: Veztar
  Flask Ubuntu Server Not Running Wheel 0 2,010 Jul-14-2020, 08:12 PM
Last Post: Wheel
  Running Flask web on other IP than 127.0.0.1 popolon59 1 2,122 Mar-29-2020, 10:02 AM
Last Post: Larz60+
  Error after a few minutes of running julio2000 10 5,402 Feb-05-2020, 11:05 PM
Last Post: julio2000
  error when running headless selenium julio2000 2 4,559 Feb-01-2020, 12:41 PM
Last Post: julio2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020