How to install Flask on Windows?

前端 未结 10 1113
灰色年华
灰色年华 2020-12-03 01:02

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

相关标签:
10条回答
  • 2020-12-03 01:43

    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.

    0 讨论(0)
  • 2020-12-03 01:43

    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

    0 讨论(0)
  • 2020-12-03 01:46

    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
    
    0 讨论(0)
  • 2020-12-03 01:54

    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.

    0 讨论(0)
  • 2020-12-03 01:55

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

    0 讨论(0)
  • 2020-12-03 01:58

    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

    0 讨论(0)
提交回复
热议问题