Python Flask Windows Development Environment Setup

No more struggles Windows Python development! I’ve found this is the best way to configure your dev environment.
This has made things much easier to get started and less of a headache overall.

We use Virtual Environment so we can test python code in encapsulated environments and to also avoid filling our base Python installation with a bunch of libraries we might use for only one project.

But Virtual Environments can be tricky if you don’t establish a good workflow. I’ll show you how to setup your python environment from Scratch and then do a very simple workflow using Flask.

4 Steps:
Install Python
Install Pip
Install VirtualEnv
Install VirtualEnvWrapper-win

Install Python:

First Go to the Python Downloads Site.

As of March 2015 the download you want for a standard windows machine is Windows x86-64 MSI installer (The other download is for servers). Its circled here:


Run the installer!
You’ll come across this page in the installer:


You’ll want to scroll down and add it to the path. If you don’t that’s okay. You can add it later.
Adding Python to the PATH will allow you to call if from the command line.

After the installation is complete double check to make sure you see python in your PATH. You can find your path by opening your control panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> Selecting Path -> Edit ->

Now you’re looking at your Path. Be Careful, if you delete or add to the path accidently you may break other programs.

You need to confirm that C:\Python27; and C:\Python27\Scripts; is part of your path.

If you do not see it in your path you can simply add it at the beginning or end of the variable value box. As you can see in the image below.


Install Pip:

As of Python Version 2.7.9 Pip is installed automatically and will be available in your Scripts folder.

If you install a later version of Python I would recommend installing it according to this helpful stackoverflow post.

Pip is a Package manager for python which we will use to load in modules/libraries into our environments.

An example of one of these libraries is VirtualEnv which will help us keep our environments clean from other Libraries. This sounds really confusing but as you start using it you’ll begin to understand how valuable this encapsulation of modules/libraries can be.

To test that Pip is installed open a command prompt (win+r->’cmd’->Enter) and try ‘pip help’

You should see a list of available commands including install, which we’ll use for the next part:

Install virtualenv:

Now that you have pip installed and a command prompt open installing virtualenv to our root Python installation is as easy as typing ‘pip install virtualenv’
Like so:


Now we have virtualenv installed which will make it possible to create individual environments to test our code in. But managing all these environments can become cumbersome. So we’ll pip install another helpful package…

Install virtualenvwrapper-win:

This is the kit and caboodle of this guide.

Just as before we’ll use pip to install virtualenvwrapper-win. ‘pip install virtualenvwrapper-win’
Like so:


Excellent! Now we have everything we need to start building software using python! Now I’ll show you how buttery smooth it is to use these awesome tools!

7 Steps:
Make a Virtual Environment
Connect our project with our Environment
Set Project Directory
Pip Install

Make a Virtual Environemt:

Lets call it HelloWold. All we do in a command prompt is enter ‘mkvirtualenv HelloWold’
This will create a folder with python.exe, pip, and setuptools all ready to go in its own little environment. It will also activate the Virtual Environment which is indicated with the (HelloWold) on the left side of the prompt.


Anything we install now will be specific to this project. And available to the projects we connect to this environment.

Connect our project with our Environment:

Now we want our code to use this environment to install packages and run/test code.

First lets create a directory with the same name as our virtual environment in our preferred development folder. In this case mine is ‘dev’

See here:


HelloWold will be the root folder of our first project!

Set Project Directory:

Now to bind our virtualenv with our current working directory we simply enter ‘setprojectdir .’
Like so:


Now next time we activate this environment we will automatically move into this directory!
Buttery smooth.


Let say you’re content with the work you’ve contributed to this project and you want to move onto something else in the command line. Simply type ‘deactivate’ to deactivate your environment.
Like so:


Notice how the parenthesis disappear.
You don’t have to deactivate your environment. Closing your command prompt will deactivate it for you. As long as the parenthesis are not there you will not be affecting your environment. But you will be able to impact your root python installation.


Now you’ve got some work to do. Open up the command prompt and type ‘workon HelloWold’ to activate the environment and move into your root project folder.

Like so:


Pretty sweet! Lets get working.

Pip Install:

To use flask we need to install the packages and to do that we can use pip to install it into our HelloWold virtual environment.

Make sure (HelloWold) is to the left of your prompt and enter ‘pip install flask’
Like so:


This will bring in all the tools required to write your first web server!


Now that you have flask installed in your virtual environment you can start coding!

Open up your favorite text editor and create a new file called and save it in your HelloWold directory.

I’ve simply taken the sample code from Flask’s website to create a very basic ‘Hello World!’ server.

I’ve named the file

Once the code is in place I can start the server using ‘python’ this will run the python instance from your virtual environment that has flask.

See here:


You can now navigate with your browser to and see your new site!

Sweet. You have everything you need to start working through tutorials on Flask without worrying about gunking up your Python installations.

Let me know if you have any questions! Happy Developing!

Art Deco From Afar
Art Deco From Afar

66 thoughts on “Python Flask Windows Development Environment Setup”

  1. I do agree with all of the ideas you have presented in your post. They are really convincing and will certainly work. Still, the posts are too short for newbies. Could you please extend them a bit from next time? Thanks for the post.

  2. Hi Tim,
    This was a fantastic step-by-step guide for newbies like me to get started on Python for Windows. I have used Anaconda before but always dreaded configuration complexity. This makes it very very simple to set-up. I’ve bookmarked it as well as saved a local copy just in case 😛

  3. Hi. Thanks for the information.I have followed your instructions and I was able to run the sample helloworld code.

    Please, any time I want to start a new application, where do I start since I do not need to install python or flask again.

    Please your reply is needed urgently.


  4. Thanks for the information.I have followed your instructions and I was able to run the sample helloworld code.

    Please, any time I want to start a new application, where do I start since I do not need to install python or flask again.

    Please your reply is needed urgently.

    1. Begin where it says usage:
      These are the seven steps I use for every new project.
      7 Steps:
      Make a Virtual Environment
      Connect our project with our Environment
      Set Project Directory
      Pip Install

  5. I am more than grateful. I have gone through series of tutorials on pip but they never worked until i met your website. It worked perfectly.

  6. I actually do agree with all the ideas you’ve presented inside your publish. They are simply convincing and can certainly work. Still, the posts are extremely short for starters. Would you please extend them a little next time? Thanks.

  7. Great workaround. I didn’t know you can just add something on the path in case something’s missing as compared to reinstalling it altogether.

  8. The requested URL was not found on the the error i am getting can you help me with this.
    i did all the 7 steps you mentioned. though the serve is running on i get this in my ngnix error log.”2017/06/14 14:24:12 [error] 13108#8008: *3 CreateFile() “C:\nginx-1.12.0/html/hello” failed (2: The system cannot find the file specified), client:, server: localhost, request: “GET /hello HTTP/1.1”, host: “localhost:80”

  9. Hello everyone,
    My office network uses a configuration script for the proxy.
    So, the flask application I have created doesn’t work & ends with an exception
    requests.exceptions.ConnectionError: HTTPSConnectionPool

    Can someone please help me resolve this & make it work behind the proxy.

  10. Hello Timbo,

    Great article and work like charm.

    But have a new configuration in Windows.

    Is is possible to relation between

    APACHE/NGINX + uWsgi(any wsgi) + FLASK ?

    We establish above environment in Linux system But issues with Window version.

    Can you help me out

  11. After scouring the internet for how to setup Flask, I must remark this this tutorial is one of the simplest and most comprehensive tutorials on how to get started using Flask for Windows users.

    Thanks for putting in the time to write this tutorial.

  12. Hi Timmy,
    My program is running but can’t be accessed thorugh the browser, site can’t be reached it said.
    Any suggestion?

    Thank you in advance


  13. Thanks for the information. I have one Question.
    how can we set local environment variable in virtual environment.
    for example i want to save my database uri in virtual environment.
    How can i do this.(i m using window for python project)

  14. thanks for the tutorial, it really helped a great deal. but i get an error2 message whenever i try to run the ‘python’ i get an errror message that says:
    (HelloWorld) C:\Users\Elotech\dev\Helloworld>python
    (null): can’t open file ‘’: [Errno 2] No such file or directory.
    please do help out thanks.
    mean while i have the python script in my Helloworld folder in dev.

  15. I am facing an issue after running command of python its not showing anything and no result is in cmd as well please guide what i have missed followed every single step.

  16. Thank you.
    I have followed all the instructions, however when I tpye python there is no retun. Not sure what I missed.

    Thank you again for the detailed explanation.

  17. Hi tim,
    i always wanted to learn how to set virtual environment in python and connect it and use it in my project this indeed helped a lot.

    thank you so much.

  18. Hello Tim,
    First of all, thanks a lot for this guide. It looks pretty simple and straightforward. I’ve followed the instructions and everything went well until I ran the command:

    mkvirtualenv calculator

    in which I wanted to test run the Python Calculator example code I found online.

    The command seemed to have triggered an endless loop as it kept repeating the following for as long as I let it run:

    “Running virtualenv with interpreter C:/…” indicating the full path to python.exe.

    What did I miss?

    Before that though, after running the pip commands to install virtualenv and virtualenvwrapper-win, there was a warning suggesting I should upgrade pip from 19.0.3 to 19.1.1 which I did, but got an Access Denied error after the new version had finished installing and the old one had been removed.

    Thanks for your help

  19. I am successfully using the simple Twisted Web server on Windows for Flask web sites.
    Are others also successfully using Twisted on Windows, to validate that configuration?

    if name == “main”:
    reactor_args = {}

    def run_twisted_wsgi():
    from twisted.internet import reactor
    from twisted.web.server import Site
    from twisted.web.wsgi import WSGIResource

    resource = WSGIResource(reactor, reactor.getThreadPool(), app)
    site = Site(resource)
    reactor.listenTCP(5000, site)**reactor_args)

    if app.debug:
    # Disable twisted signal handlers in development only.
    reactor_args[‘installSignalHandlers’] = 0
    # Turn on auto reload.
    import werkzeug.serving
    run_twisted_wsgi = werkzeug.serving.run_with_reloader(run_twisted_wsgi)


    if name == “main”:

  20. Anyone got an idea why ‘workon name_of_project’ is not working for me? I have followed the steps in this tutorial up to deactivate stage. The next step which is reactivate using workon doesn’t work for me meanwhile i have installed workon.
    Thank you

    1. I think the answer lies in the name itself. Localhost is not on the web. It lies in your own machine. That is why you can’t see the from another machine.
      (Actually I too was searching for an answer as my “” didn’t compile properly. It was complaining “NameError: name ‘app’ is not defined”! )

  21. I think the answer lies in the name itself. Localhost is not on the web. It lies in your own machine. That is why you can’t see the from another machine.

  22. Thank a lot – it took just 20 min to set up. for v.3.7.
    Only 2 line of code were missing from “A Minimal Application”:
    if __name__ == “__main__”:

Leave a Reply

Your email address will not be published. Required fields are marked *