How to run a Python script on your Windows computer

Micke Kring Micke Kring · · 2 min read
Läs på svenska
How to run a Python script on your Windows computer

If you’ve seen some of my posts where I’ve shared my small tools and similar and would like to try them yourself — but feel like you don’t know what Python is, then this article is for you. Here I go through how to install Python, how to install modules (a form of add-on) and finally how to run a script. It’s nothing particularly difficult, like many things once you know how.)

In the video above I’m drawing from my article and code “How to automate grade checking and creating grade statistics”

Install Python

You can install Python in several ways, but if you’re on a work computer and you use Software Center, you can find Python there. If you don’t use that, you can also find Python in the Microsoft Store.

Create a folder on your computer to run code from

In the video we create a folder on the local hard drive to run code from. We name the folder code for simplicity. If you have several different scripts that you run, it can be smart to create subfolders for each script inside code.

Install Python modules

When you’ve found a script you want to test, the author will often write what prerequisites you need to run the script. Often you need to install some modules for Python — and we do that with pip3 install name_of_the_module, for example pip3 install tinydb

Download the script / code and put it in your folder on the hard drive

If you want to run my script that automates grade checking, I’ve chosen to put my code on GitHub. Here we download the code from GitHub and put the files in our code folder on our local hard drive.

Run the script

In the final part of the video we use the command prompt to navigate to our code folder and then run the code. A small reminder here; c: takes you to the drive cd code takes you to the code folder dir shows what is in the folder you’re in python main.py runs the Python script named main.py

Questions?

If you have questions just give me a shout! :)