KEMBAR78
How to Install Python on Linux | PDF
How to Install Python on Linux
Python is one of the oldest programming languages around. However, with the onset of Machine
Learning, Python has been given a new lease of life. It has become a popular tool for both Machine
Learning and Deep Learning.
Currently, Python is available as two distinct versions. That is Python 2 and Python 3.
Ubuntu comes with Python pre-installed. So when you open the terminal and enter python at the
command prompt, Python should start. You will see the version of Python that is currently on your
system.
To upgrade to the latest version of Python, exit the python shell by typing exit()
Now, enter the following command in the terminal:
sudo apt-get upgrade
This will upgrade all the software on your system.
If Python has not been installed on your system, you can follow the instructions below to install
Python.
Selecting a Version of Python
With two great choices, how do you decide on which one to use? It all comes down to
compatibility. Certain programmes or libraries that you want to use in your project may only be
compatible with one version of Python.
So keep your end goal in mind when selecting a version. If you want to have more flexibility when
it comes to Python projects, just download, both versions.
Begin Installation
Note: These steps can be followed to install both versions of Python.
1. Visit https://www.python.org/
2. Select the 'Downloads' tab. A drop down menu will appear.
3. To the right of the drop down menu, you will see the latest versions of python that are
available for Ubuntu. The first button provides the latest version of Python 3 and the second
button provides the option for the latest version of Python 2. Once you click an option, the
download will begin.
4. Once installation is complete, open the terminal and type cd Downloads/
5. You will enter the downloads folder. Now type the command ls.
6. This will let you view the contents of your Downloads folder and check to make sure that
the Python installer has been downloaded.
7. Now extract the contents of the Python installer by using the command tar xvf 
Python-3.6.4.tar.xz
8. Make sure to enter the correct version number, then type enter.
9. Now enter the extracted folder by typing the command cd Python-3.6.4/
10. Once you have entered the folder, use the command ./configure
11. This begins the installation process and will take a while depending on your system's
memory and speed.
12. Once it has completed, use the command sudo make
13. For security purposes, you will be asked to enter your password before proceeding. Enter
your password and hit the enter button.
14. The file takes a while to be created.
15. Once it has completed, type the command sudo make install
16. Once again this will take a few minutes.
17. Once the process is complete, you should get a message saying that al requirements are
satisfied. This means that you have successfully installed Python on your system.
Troubleshooting
1. You may get an error message saying that pip requires ssl.
2. To install ssl, us the command sudo apt-get install libssl-dev openssl
3. Once this is completed, use the command sudo make install
4. Python should now be successfully installed on your system.
Testing Your Installation
Now that you have downloaded Python, test it to make sure it is working correctly.
1. Open the Ubuntu Terminal.
2. Type python3 or python2 (depending on which version you would like to use) and press
enter.
3. The version of your Python installation should show up.
4. To test it further, run python by typing python and pressing enter.
5. Now type the command print("Hello World!") and press enter.
6. This will print the words Hello World in the terminal.
 
Congratulations! You have installed Python on your system.

How to Install Python on Linux

  • 1.
    How to InstallPython on Linux Python is one of the oldest programming languages around. However, with the onset of Machine Learning, Python has been given a new lease of life. It has become a popular tool for both Machine Learning and Deep Learning. Currently, Python is available as two distinct versions. That is Python 2 and Python 3. Ubuntu comes with Python pre-installed. So when you open the terminal and enter python at the command prompt, Python should start. You will see the version of Python that is currently on your system. To upgrade to the latest version of Python, exit the python shell by typing exit() Now, enter the following command in the terminal: sudo apt-get upgrade This will upgrade all the software on your system. If Python has not been installed on your system, you can follow the instructions below to install Python. Selecting a Version of Python With two great choices, how do you decide on which one to use? It all comes down to compatibility. Certain programmes or libraries that you want to use in your project may only be compatible with one version of Python. So keep your end goal in mind when selecting a version. If you want to have more flexibility when it comes to Python projects, just download, both versions. Begin Installation Note: These steps can be followed to install both versions of Python. 1. Visit https://www.python.org/ 2. Select the 'Downloads' tab. A drop down menu will appear. 3. To the right of the drop down menu, you will see the latest versions of python that are available for Ubuntu. The first button provides the latest version of Python 3 and the second button provides the option for the latest version of Python 2. Once you click an option, the download will begin. 4. Once installation is complete, open the terminal and type cd Downloads/ 5. You will enter the downloads folder. Now type the command ls. 6. This will let you view the contents of your Downloads folder and check to make sure that the Python installer has been downloaded. 7. Now extract the contents of the Python installer by using the command tar xvf  Python-3.6.4.tar.xz 8. Make sure to enter the correct version number, then type enter.
  • 2.
    9. Now enterthe extracted folder by typing the command cd Python-3.6.4/ 10. Once you have entered the folder, use the command ./configure 11. This begins the installation process and will take a while depending on your system's memory and speed. 12. Once it has completed, use the command sudo make 13. For security purposes, you will be asked to enter your password before proceeding. Enter your password and hit the enter button. 14. The file takes a while to be created. 15. Once it has completed, type the command sudo make install 16. Once again this will take a few minutes. 17. Once the process is complete, you should get a message saying that al requirements are satisfied. This means that you have successfully installed Python on your system. Troubleshooting 1. You may get an error message saying that pip requires ssl. 2. To install ssl, us the command sudo apt-get install libssl-dev openssl 3. Once this is completed, use the command sudo make install 4. Python should now be successfully installed on your system. Testing Your Installation Now that you have downloaded Python, test it to make sure it is working correctly. 1. Open the Ubuntu Terminal. 2. Type python3 or python2 (depending on which version you would like to use) and press enter. 3. The version of your Python installation should show up. 4. To test it further, run python by typing python and pressing enter. 5. Now type the command print("Hello World!") and press enter. 6. This will print the words Hello World in the terminal.   Congratulations! You have installed Python on your system.