In this article, we'll install Python on Windows step-by-step. First, we'll examine what is included in the installer, then we will install it using default settings and after it is done, we are going to test if the installation was successful. Finally, we'll end the tutorial by making a simple hello-world Python program.
Let's look at what else is included in the Python installer before we start with the installation process.
What else can we install during Python installation
At the start of the installation process, if we select the "default installation", all of the tools and manuals mentioned below will be included and if we select "custom installation", we can choose what to include and what to skip.
Python Launcher
Python Launcher (py command in the terminal) is installed by default since Python 3.3. It is a tool that acts as a shortcut to all installed versions of Python available in the system and it allows scripts or command-line to specify a Python version and then it launches that version. More information about it can be found here.
The pip command
The pip is a package manager for Python. We use it to install and manage packages and modules, mostly from the Python Package Index repository, but could also be used for other Python repositories, GitHub, the requirements.txt file of the project, and other sources.
Python IDLE Shell
Python IDLE (Integrated Development and Learning Environment) is a GUI Python interactive interpreter. It functions as a basic IDE editor. It has syntax highlighting, auto-completion, and debugging. More information about the IDLE is available here.
python
command without parameters. To exit the interpreter, we can use either quit(), exit() or CTRL+Z.Python Documentation
Python documentation will be included in the default installation. It will also include the documentation of the installed modules and packages in your system. When you install additional modules/packages with the pip
command, those get included too.
Installing Python on Windows
In this section, we will install Python on Windows and then test it to see if it was successfully installed.
Testing the Python installation
To see if Python was successfully installed, launch the command prompt (cmd) or PowerShell and run the following command:
This should return the Python version that is currently installed.
The python' is not recognized as an internal or external command error
If you get the message "'python' is not recognized as an internal or external command, operable program or batch file." it is possible you forgot to enable the checkbox for the Add Python 3.7 to PATH in the first step of the installation. We can fix this by going through the following steps:
- Close the command prompt/PowerShell terminal.
- Run the installer again (no need to uninstall)
- Choose Modify
- First, it will list "Optional Features". We are fine with what we installed, so click Next.
- Next, it will list "Advanced Options". Enable the checkbox for the "Add Python for environment variables" and click Install.
Launch the terminal once more and try running the python --version
command again.
Creating a simple hello-world script
Let's write a simple Python script that will display the hello world message. Create a hello.py
file somewhere on your computer with the following code:
print("Hello World")
Inside the Command prompt/PowerShell, go to the location of the hello.py
file and run the following command:
This should display the "hello world" on the terminal.
Conclusion
In this tutorial, we learned how to install Python on Windows System. The Python installer also includes other tools and documentation that are automatically added with the default installation. We then tested if the Python was installed successfully and then created and ran a simple hello-world script.
0 Comments