How to Install Python?

Nibesh Khadka
4 min readApr 13, 2021

Find the steps the install Python on Linux and Windows OS.

Linux OS (Ubuntu 20)

Installation

Python is preinstalled in Linux operating systems. Check the version in your terminal.

  1. Open the terminal by pressing the windows key then type cmd
  2. enter the command
python -V<output>
Python 3.8.5

It means I have the Python 3.8.5 version installed. By the time I am writing this blog stable version of python 3.9.4 is installed.

The meaning behind the three numbers you saw in versions are, for instance, 3.9.4 → 3 is the major version, 9 is the minor version and 4 is the sub-mini version.

To install a specific version of Python. In your terminal type the following command

#First update your OS
sudo apt update
#Enter password that will be asked#Install
sudo apt install python3.9

Here we installed Python 3.9 u don’t have to type the sub-mini version.

Windows OS

Go to the link https://www.python.org/downloads/windows/. Choose the latest from the stable version.

Find out with package to install: 32-bit or 64-bit

For Windows 10 or 8, To check that follow this

  1. Select the Start(windows) button, then select Settings > System > About
  2. At the right, under Device specifications, see System type.

In this image, you can see its 64 bits, yours might be different.

Now that we know the system type let's continue with the installation, for Windows 10. Make sure to download the “Windows installer” not “Embeddable Package”. I am downloading the 3.9.4 version, yours can be different depending on time.

Download and then open the file, a new window, and follow the instructions.

I checked both checkboxes and also picked the Install Now option not Custom option. Then, u should see a progress window similar to the following one.

After you are done open the command prompt, and check the version.

For Mac Os please find some blogs, I think it should not be much different from Linux but not exactly the same either.

Virtual Environment

Python programming language has a lot of libraries, a big community, and many releases. It's a good thing however, sometimes some updates are not backward compatible which can cause serious problems like software crashes, some functionality not working, etc.

Hence, comes the solution Virtual Environment. It's an extra inventory where we can install specific versions of software and unless u specifically update this environment outside environment won’t affect it.

For instance, I want to work on Django version 2 to make a web application in one project, whereas Django3 is another web project. I can create two virtual environments for each project and install Django 2 in one and 3 in another.

Creating a Virtual Environment Using PIP

PIP is a package management system for Python. It helps to install libraries and packages for Python programming language.

Pip Installation

Instruction is similar for both Linux and Windows.

pip --version#output should be 
pip 20.2.3 from <your path to python file>

To upgrade to the latest pip version.

python -m pip install --upgrade pip

Create Virtual Environment

It's the same for both OSs accept for the final activate command.

  1. First install virtualenv. In your terminal.
pip install virtualenv

You will see some progress messages. If you have not upgraded your pip you will also see a warning message.

2. Create a virtual environment. The command is virtualenv name_of_your_environment.

virtualenv python3_env

This will create a Python environment named python3_env it will also install pip, and some other packages as you will see in the terminal.

3. To use this environment you have to manually activate it. First, you have to go to your Home directory. A path for the Home folder should be like “C:\Users\your_user_name” where your_user_name=” Name of your computer”. After that to activate the virtual environment type:

#For windows : 
python3_env\Scripts\activate
#For linux or mac
source python3_env/bin/activate

Be careful about backslash and front-slash, and also uppercase and lowercase.

Now after it's activated u should see your environment name inside the bracket on the left side as in the picture below.

Now that the environment is activated, we can install and make software with our desired version.

4. To deactivate the virtual environment.

deactivate

This was a short Python installation and set-up guide for beginners. I hope u didn’t encounter any errors. If you did get any errors then please leave a comment, I will reply as soon as I can. Thanks for the support, please don’t forget to like the post if it was helpful.

--

--

Nibesh Khadka

Software Developer, Content Creator and Wannabe Entrepreneur