How to setup python on Windows

Apparently a lot of people are struggling with simple setup of python environment on Windows. When I first started coding with python, the environment setup took me longer than it should. I’m going to give simple fast instructions with easiest ways to setup python on Windows.

Install canopy

If you quickly need to setup python and write some code, I would suggest to go with Canopy. It’s great for scientific computing, data analysis and engineering. It’s free and includes 200+ most popular python packages.

Simply download the installer click next, next.. and you are half way done. When installation and environment setup is completed, select Editor from Welcome to Canopy window. Create a new file, write some code and run it by clicking on green triangle at the top menu or use Ctrl+R

Install python packages in canopy

To install python package in canopy, simply start canopy and from welcome menu select Package Manager. Select Available tab from the left side and type selenium in search field at the top. That should display selenium package. Select selenium package and click on blue install button. Now you can import selenium package in your scripts if you are using canopy.

Install python

Firstly, download python and when installing select following options:
* Install for all users
* Set python path: “C:\Python27” (it’s just easier if it’s on “C:\”)

Next, in order to use python in command line you have to set path to python in windows environment variables. Follow the instructions below or use google:

1. Right-click on windows start icon and select System.
2. On the right side of System window select Advanced system settings.
3. In System properties window click on Environment variables button.
4. In environment variables window select variable Path and click on Edit button.
5. Click on New button and add C:\Python27
6. Click on New button and add C:\Python27\Scripts

Open command line, type python and if it displays the following text, you did everything right:

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Install pip, virtualenv

As of Python 2.7.10, pip is automatically installed as part of the Python for Windows installer, if you downloaded python from above link, your version is 2.7.12.

To setup virtualenv open command line and type pip install virtualenv, it should display Successfully installed virtualenv-15.0.3 (version numbers can change).

Once that’s done your basic python environment is setup. You can now install most of the python packages by typing pip install package-name in command line. Here are some examples:
* pip install selenium
* pip install pypiwin32
* pip install django

Python IDE

pycharm-logo-big

To edit and run python scripts I would suggest to use PyCharm. It’s easy to setup and use. Just make sure that you download Community edition, otherwise there’s only 30 day trial period for professional edition. When you first use PyCharm it might ask to setup python interpreter, in order to do that open Settings/Preferences (Ctrl+Alt+S), select Project interpreter and from the top project interpreter drop down menu select 2.7.12 (C:\Python27\python.exe). Apply and save settings by clicking on Apply and OK buttons.

2 thoughts on “How to setup python on Windows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s