How to install Python on Windows

Install Python, run an IDE, and start coding right from your Microsoft Windows desktop.
Register or Login to like
hands programming

WOCinTech Chat. Modified by Opensource.com. CC BY-SA 4.0

So you want to learn to program? One of the most common languages to start with is Python, popular for its unique blend of object-oriented structure and simple syntax. Python is also an interpreted language, meaning you don't need to learn how to compile code into machine language: Python does that for you, allowing you to test your programs sometimes instantly and, in a way, while you write your code.

Just because Python is easy to learn doesn't mean you should underestimate its potential power. Python is used by movie studios, financial institutions, IT houses, video game studios, makers, hobbyists, artists, teachers, and many others.

On the other hand, Python is also a serious programming language, and learning it takes dedication and practice. Then again, you don't have to commit to anything just yet. You can install and try Python on nearly any computing platform, so if you're on Windows, this article is for you.

If you want to try Python on a completely open source operating system, you can install Linux and then try Python.

Get Python

Python is available from its website, Python.org. Once there, hover your mouse over the Downloads menu, then over the Windows option, and then click the button to download the latest release.

Downloading Python on Windows

Alternatively, you can click the Downloads menu button and select a specific version from the downloads page.

Install Python

Once the package is downloaded, open it to start the installer.

It is safe to accept the default install location, and it's vital to add Python to PATH. If you don't add Python to your PATH, then Python applications won't know where to find Python (which they require in order to run). This is not selected by default, so activate it at the bottom of the install window before continuing!

Select "Add Python 3 to PATH"

Before Windows allows you to install an application from a publisher other than Microsoft, you must give your approval. Click the Yes button when prompted by the User Account Control system.

Windows UAC

Wait patiently for Windows to distribute the files from the Python package into the appropriate locations, and when it's finished, you're done installing Python.

Time to play.

Install an IDE

To write programs in Python, all you really need is a text editor, but it's convenient to have an integrated development environment (IDE). An IDE integrates a text editor with some friendly and helpful Python features. IDLE 3 and Pycharm (Community Edition) are two great open source options to consider.

IDLE 3

Python comes with an IDE called IDLE. You can write code in any text editor, but using an IDE provides you with keyword highlighting to help detect typos, a Run button to test code quickly and easily, and other code-specific features that a plain text editor like Notepad++ normally doesn't have.

To start IDLE, click the Start (or Window) menu and type python for matches. You may find a few matches, since Python provides more than one interface, so make sure you launch IDLE.

IDLE 3 IDE

If you don't see Python in the Start menu, reinstall Python. Be sure to select Add Python to PATH in the install wizard. Refer to the Python docs for detailed instructions.

PyCharm IDE

If you already have some coding experience and IDLE seems too simple for you, try PyCharm (Community Edition), an open source IDE for Python. It has keyword highlighting to help detect typos, quotation and parenthesis completion to avoid syntax errors, line numbers (helpful when debugging), indentation markers, and a Run button to test code quickly and easily.

To install it, visit the PyCharm IDE website, download the installer, and run it. The process is the same as with Python: start the installer, allow Windows to install a non-Microsoft application, and wait for the installer to finish.

Once PyCharm is installed, double-click the PyCharm icon on your desktop or select it from the Start menu.

Tell Python what to do

Keywords tell Python what you want it to do. In IDLE, go to the File menu and create a new file. In PyCharm, click the New Project button.

In your new, empty file, type this into IDLE or PyCharm:

print("Hello world.")
  • If you are using IDLE, go to the Run menu and select the Run Module option.
  • If you are using PyCharm, click the Run button in the top right corner of the window.

Run code

opensource.com

Any time you run code, your IDE prompts you to save the file you're working on. Do that before continuing.

The keyword print tells Python to print out whatever text you give it in parentheses and quotes.

That's not very exciting, though. At its core, Python has access to only basic keywords like print and help, basic math functions, and so on.

Use the import keyword to load more keywords. Start a new file and name it pen.py.

Warning: Do not call your file turtle.py, because turtle.py is the name of the file that contains the turtle program you are controlling. Naming your file turtle.py confuses Python because it thinks you want to import your own file.

Turtle is a fun module to use. Add this code to your file:

import turtle

turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.end_fill()

See what shapes you can draw with the turtle module.

To clear your turtle drawing area, use the turtle.clear() keyword. What do you think the keyword turtle.color("blue") does?

Try more complex code:

import turtle as t
import time

t.color("blue")
t.begin_fill()

counter = 0

while counter < 4:
    t.forward(100)
    t.left(90)
    counter = counter+1

t.end_fill()
time.sleep(2)

Notice that turtle, in this example code, has not only been imported, but it's also been given the shorter nickname t, which is quicker and easier to type. This is a convenience function in Python.

Challenge

As a challenge, try changing your script to get this result:

Example Python turtle output

Once you complete that script, you're ready to move on to more exciting modules. A good place to start is this introductory dice game.

Stay Pythonic

Python is a fun language with modules for practically anything you can think to do with it. As you can see, it's easy to get started with Python, and as long as you're patient with yourself, you may find yourself understanding and writing Python code with the same fluidity as you write your native language. Work through some Python articles here on Opensource.com, try scripting some small tasks for yourself, and see where Python takes you. To really integrate Python with your daily workflow, you might even try Linux, which is natively scriptable in ways no other operating system is. You might find yourself, given enough time, using the applications you create!

Good luck, and stay Pythonic.


This article was originally published in August 2019 and has been updated by the author.

What to read next
Seth Kenlon
Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time.

6 Comments

You may have to also consider whether you are going to use Python for scripting in some API-enabled piece of software. Scribus requires at least Python 2.7, and I'm not sure if Python 3+ will work. At the same time, the Scribus that you download from Sourceforge has Python 2.7 built into it. This is a somewhat limited Python, though, and you may want/need other packages. The trick is to install Python 2.7 or better and any packages you need, then go to the directory where the Scribus-installed Python is and either rename it, or delete it*. When Scribus starts, it will first look for its own Python, and if it can't find it, check the system.

* Hint: on general principles, it's better first to just rename and make sure your Python works with Scribus before deleting it in Scribus.

Great! Tx! and yes... in fact i have 2 versions of Python installed rigth now

Thanks for providing in-depth instructions to install Python. I previously Messed up with Python Installation, where i took Microsoft Windows 10 Support help to Reset it.

By following your Steps, I could do it very easily and quickly. You Step wise Images helped me a lot which is very easy to understand and implement.

Thanks,
Mahesh

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.