How to install Flask on Windows?

前端 未结 10 1114
灰色年华
灰色年华 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 02:00

    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.

    0 讨论(0)
  • 2020-12-03 02:03

    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/

    0 讨论(0)
  • 2020-12-03 02:05

    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

    0 讨论(0)
  • 2020-12-03 02:07

    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

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