[python] How to install Flask on Windows?

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.

This question is related to python flask

The answer is


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!!!


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\\AppData\Local\Programs\Python\Python35\Scripts

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


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
>env\Scripts\activate
>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


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:\Python27\Scripts 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


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:\Python27\Scripts

  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


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

D:\Python37\Scripts>pip install Flask

it take some movement to download the package.


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/


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

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%\chocolatey\bin

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