How to install Flask on Windows?

Question:

I have a project to do for after create a webpage that display the latest weather from my CSV file.

I would like some details how to do it (don’t really get the http://flask.pocoo.org/docs/installation/#installation installation setup)

Can anyone mind explain me how to do it simply?

Thanks.

I’m running on Windows 7, with the Windows Powershell.

Asked By: Nardrek

||

Answers:

Install pip as described here: How do I install pip on Windows?

Then do

pip install flask

That installation tutorial is a bit misleading, it refers to actually running it in a production environment.

Answered By: Uku Loskit

On Windows, installation of easy_install is a little bit trickier, but still quite easy. The easiest way to do it is to download the distribute_setup.py file and run it. The easiest way to run the file is to open your downloads folder and double-click on the file.

Next, add the easy_install command and other Python scripts to the command search path, by adding your Python installation’s Scripts folder to the PATH environment variable. To do that, right-click on the “Computer” icon on the Desktop or in the Start menu, and choose “Properties”. Then click on “Advanced System settings” (in Windows XP, click on the “Advanced” tab instead). Then click on the “Environment variables” button. Finally, double-click on the “Path” variable in the “System variables” section, and add the path of your Python interpreter’s Scripts folder. Be sure to delimit it from existing values with a semicolon. Assuming you are using Python 2.7 on the default path, add the following value:

;C:Python27Scripts
And you are done! To check that it worked, open the Command Prompt and execute easy_install. If you have User Account Control enabled on Windows Vista or Windows 7, it should prompt you for administrator privileges.

Now that you have easy_install, you can use it to install pip:

easy_install pip

Answered By: Priyansh

heres a step by step procedure (assuming you’ve already installed python):

  1. first install chocolatey:

open terminal (Run as Administrator) and type in the command line:

C:/> @powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1‘))” && SET PATH=%PATH%;%ALLUSERSPROFILE%chocolateybin

it will take some time to get chocolatey installed on your machine. sit back n relax…

  1. now install pip. type in terminal
    cinst easy.install pip

  2. now type in terminal:
    pip install flask

YOU’RE DONE !!!
Tested on Win 8.1 with Python 2.7

Answered By: Anum Sheraz

First install flask using pip,

pip install Flask

* If pip is not installed then install pip

Then copy below program (hello.py)

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

Now, run the program

python hello.py

Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Just copy paste the above address line in your browser.

Reference: http://flask.pocoo.org/

Answered By: imbond

I have windows 10 and pythonv3.5. @uku answer is correct. however, problem I was facing is that where are python scripts which are to be added in environment variable. So I found out that we need to add

C:Users\AppDataLocalProgramsPythonPython35Scripts

above location as environment variable. If it still doesnot work search for python in C Drive then find out script locations.

Answered By: Manjot Singh

First: I assumed you already have Python 2.7 or 3.4 installed.

1: In the Control Panel, open the System option (alternately, you can right-click on My Computer and select Properties). Select the “Advanced system settings” link.

  1. In the System Properties dialog, click “Environment Variables”.

  2. In the Environment Variables dialog, click the New button underneath the “System variables” section.

  3. if someone is there that above is not working, then kindly append to your PATH with the C:Python27 then it should surely work. C:Python27Scripts

  4. Run this command (Windows cmd terminal): pip install virtualenv

  5. If you already have pip, you can upgrade them by running:

    pip install –upgrade pip setuptools

  6. Create your project. Then, run virtualenv flask

Answered By: Ansi

Assuming you are a PyCharm User, its pretty easy to install Flask
This will help users without shell pip access also.

  • Open Settings(Ctrl+Alt+s) >>
  • Goto Project Interpreter>>
  • Double click pip>> Search for flask
  • Select and click Install Package ( Check Install to site users if intending to use Flask for this project alone
    Done!!!

Cases in which flask is not shown in pip:
Open Manage Repository>>
Add(+) >> Add this following url

https://www.palletsprojects.com/p/flask/

Now back to pip, it will show related packages of flask,

  • select flask>>
  • install package>>

Voila!!!

Answered By: Ben J'o

If You are using windows then go to python installation path like.

D:Python37Scripts>pip install Flask

it take some movement to download the package.

Answered By: Sufiyan

you are a PyCharm User, its good easy to install Flask
First open the pycharm press
Open Settings(Ctrl+Alt+s)
Goto Project Interpreter

Double click pip>>
search bar (top of page) you search the flask and click install package 

such Cases in which flask is not shown in pip: Open Manage Repository>> Add(+) >> Add this following url

https://www.palletsprojects.com/p/flask/

Now back to pip, it will show related packages of flask,

select flask>>
install package
Answered By: mujahid Malik-arain

https://www.youtube.com/watch?v=QjtW-wnXlUY&t=38s

Follow as in the url

This is how i do :
1) create an app.py in Sublime Text or Pycharm, or whatever the ide, and in that app.py have this code

from flask import Flask

app = Flask(__name__)

@app.route('/')
def helloWorld():
    return'<h1>Hello!</h1>' 

This is a very basic program to printout a hello , to test flask is working.I would advise to create app.py in a new folder, then locate where the folder is on command prompt
enter image description here
type in these line of codes on command prompt

>py -m venv env
>envScriptsactivate
>pip install flask

Then

>set FLASK_APP=app.py
>flask run

Then press enter all will work
The name of my file is app.py, give the relevant name as per your file in code line

set FLASK_APP=app.py

Also if your python path is not set, in windows python is in AppData folder its hidden, so first have to view it and set the correct path under environment variables. This is how you reach environment variables
Control panel ->> system and security ->> system ->> advanced system setting
Then in system properties you get environment variables

Answered By: Dulangi_Kanchana
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.