Welcome to the first part of the Python basics series! In this series, you'll be learning Python from the ground up, from installation and tools for writing your code to deploying your first Python application on the web!
In this part, you'll learn how to install and configure the latest version of Python on your Windows machine.
This tutortial assumes you don't already have Python installed on your machine, however if you do, you'll still be albe to follow along and install the latest version.
Let's get started!
Downloading the Python installer
Head on over to the Python website at python.org and navigate to the Downloads tab at the top of the page
As you hover over the downloads tab, you'll see a dropdown with a button just underneath "Download for Windows"
Go ahead and click thbat button to download the installer. Once downloaded, click on the installer to launch it.
Once you've launched the installer, you'll notice a check box at the bottom that says "Add Python 3.7 to path"
Tip - You may be downloading a newer version which may have a different version number.
Make sure you tick the "Add Python to path" checkbox. Once you've check it, click on the "Install now" text and let the installer go to work.
You should see a "Setup was successful" message, meaning Python has been installed!
We're going to test our installation of Python by running the
python command in a command prompt.
If you've never used the command prompt before, don't worry! It's just a text based way to interract with a computer.
Head over to your Windows search bar and search for
command prompt. Click on it to launch a new window.
In the command prompt, simply enter the following:
You should see something that looks like this:
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
Perfect! The Python version we just installed is now on our system and can be accessed through the command prompt.
Tip - The version you just downloaded should match the version showed after running the
It's as simple as that. You're now ready to start using Python on your Windows machine. Go ahead to the next episode in this series to continue on your learning journey.
If you already have Python installed on your system and need to install a newer version, or you've installed Python but when you run the
python command in the command prompt and get a different version to what you've just installed, continue on with this guide.
Managing Python PATH
The Python PATH is an environment variable on your machine that Python will use to find versions of Python on your system.
When you run
python in the command prompt, it will search through the PATH environment variable to find a version to run!
Chances are, if you already had Python installed on your system and downloaded a newer version, your PATH may still be pointing to the older version. Let's go ahead and fix that.
In the Windows search bar, enter
environment and you should be prompted with an option to
Edit the system environment variables. Go ahead and click on it.
It will launch a new window. Click on the botton that says
Environment variables, which will also launch a new window.
In the top section of the window, you should see an entry called
PATH. Click on it to highlight it then click on the button just below titled
If you have multiple version of Python installed, you'll see a few entries with the Python version number, and another one with the same version number followed by
To ensure you're running the latest version, click on the entry with the latest version number, then click on the
Move up button to the right of the window and move it up to the top.
You then need to do the same with the entry that includes the version number and
You should end up with something similar to the following:
C:\Users\julian\AppData\Local\Programs\Python\Python37-32\Scripts\ C:\Users\julian\AppData\Local\Programs\Python\Python37-32\ C:\Users\julian\AppData\Local\Programs\Python\Python36\Scripts\ C:\Users\julian\AppData\Local\Programs\Python\Python36\
Tip - Our version numbers may be different depending on what versions you have installed!
As you can see, we have 2 versions installed:
We moved both entries for Python37-32 to the top so Python will default to this version!
To test it out, head back over to your command prompt and run the
python command just like above. You should see the Python interpreter launch with the version you've just moved to the top of your path!
Now you're ready to start learning! Head on over to the next part of this series to continue on with your learning. If you have any problems, feel free to drop a commant below and we'll do our best to help you out!