Install python on windows PC

Last time I described how to install python on Debian or Raspberry Pi. If you are a beginner and have a windows PC, here is my short tutorial on how to install python AND pyserial on a windows PC. Since I’m interested in Arduino, I will certainly need a serial module in python to talk to Arduino, such as sending Real time (yyyy/mm/dd hh:mm:ss or epoch) to Arduino to set its Real Time Clock or collect data from Arduino.

Python as of the writing has two main versions, Python 2.x and 3.x. The latest 2.x is 2.7.11. Lots of code have been developed on Python 2.x so many people still hang on to this version. The other day I tinkered with a Raspberry Pi LCD hat (add-on) and the Adafruit Python module that drives it can only be installed on Python 2.7.11. The most current version of Python 3 is 3.5.1. We will focus on this version since it has been out for quite a while. Also, Pyserial works flawlessly on Python 3.5.1.

First, download the installer here:

https://www.python.org/downloads/release/python-351/

Go to the bottom of the page and find your PC’s version (32 or 64 bit).

Install Python. Now, you need to find where the installed Python resides so you can include its path in your system’s PATH environment variable.

For me, it is here:

C:\Users\your_username\AppData\Local\Programs\Python\Python35\

Make sure you replace your_username with your actual user name (usually shortened from your full user name in windows 10).

Right click your “This PC” icon on desktop and select “Properties”. Then go to “Advanced system settings” on the left pane.

Once the dialog pops up, select “Environment Variables” on bottom right:

Advanced system settings

Once opened, you see the top half as user variables.

Environment VariablesClick PATH and Edit. Add the following TWO paths:

C:\Users\your_username\AppData\Local\Programs\Python\Python35\

C:\Users\your_username\AppData\Local\Programs\Python\Python35\Scripts\

Save and restart your computer.

Now you should have Python installed and ready to go. Still, you will need to install various modules to expand your Python, or simply to run “that script that wants this and that module”. Lots of modules are available to Python such as pyserial (serial port support) and idlex (more customization to Python’s IDE).

To install pyserial (or any other module), first open a command prompt. Then type in:

“pip install pyserial”

The package will install automatically. You are done!

 

Leave a Reply

%d