Python programming is one of the world’s most popular programming languages and it is growing at a much faster rate than every other all-purpose programming language. This is mainly because it is a flexible language and is easy to read. It is also dependable, proficient and well-organized. Python makes it possible for users to work fast. It easily and successfully integrates into your systems resulting in improved productivity and minimal management expenses.
Placing $ in front of commands indicates that the command is just running as an ordinary user while placing # in front of a command implies that you need to run the command as root (or make use of $ sudo ). There are typically two main types of python. These are Python 2 and Python 3.
The most recent edition of python 3 is the 3.6 version. Ubuntu 18.04 and Ubuntu 17.10 by default come with Python 3.6. Older versions of Ubuntu like the Ubuntu 14.04, 16.04, 16.10 and 17.04 don’t have python 3.6 by default. It needs to be installed through the APT package manager.
Python makes use of English keywords in place of punctuation and it as well comes with less syntactical programming than other programming languages. Python helps programmers to create their program through different programming, get their desired outcomes faster while writing code easily as if a human language.
By default, Ubuntu 16.04 comes with Python 2.7 and Python 3.5. It is easy to install Python 3.6 on Ubuntu 16.04. It will only take a few minutes to get it done. Follow the step by step tips we have provided below to install the newest edition of Python 3.6 on 14.04, 16.04, 16.10 and 17.04
Step 1: Install The Prerequisites (Non-compulsory)
This step is mainly to take care of issues that may occur after installation like “zipimport.ZipImportError: difficulty decompressing data; zlib not accessible” for the omitted zlib-dev, and as well setting up the environment and getting it ready for Python designing. However, this step is optional. Run the code below:
$ sudo apt-get update $ sudo apt-getinstallbuild-essential libpq-dev libssl-dev openssl libffi-dev zlib1g-dev $ sudo apt-getinstall python3-pip python3-dev
Step 2: Login To Your Ubuntu Through SSH And Ensure All Packages Installed Are Up-to-date
This step requires you to log in to your Ubuntu 16.04 VPS while SSH serves as user root. Then, run the following commands:
ssh root@IP_Address -p Port_number and update all installed packages
Step 3: Verify The Existing Version Of Python On Your Ubuntu
To verify the existing version of Python you have, carry out the command below:
# python-V Python 2.7.12
To verify which version of Python 3 you have, try the command below:
# python3-V Python 3.5.2
Step 4: Install Python 3.6 In Ubuntu 14.04 And 16.04
Python 3.6 is cannot be installed directly. You need to either incorporate a repository and install, or merely download it before installing it. You can check whether Python 3.6 can be directly installed by running the command below:
$ apt-cachesearch python3.6
There are two different ways you can install Python 3.6 on an Ubuntu 16.04 and 14.04.
First Installation Method – With The Use Of PPA
Ubuntu 14.04 and 16.04 come with Python 2.7 and Python 3.5 by default. Personal Package Archives (PPA) helps the programmer to upload and distribute the source of Ubuntu packages to be developed and made available at an apt store through Launchpad. There is a public debate about the issues that come with PPA. Therefore, if you are using a PPA, you should carefully consider the producer of the PPA you want to use. To install Python 3.6, the most commonly utilized and trusted PPA is the J Fernyhough’s PPA.
Install the command below:
apt-get install software-properties-common python-software-properties
Run the command below to add the PPA
$ sudo add-apt-repository ppa:jonathonf/python-3.6 $ sudo apt-get update $ sudo apt-get install python3.6
Tap [ENTER] to continue or ctrl-c to cancel the addition and tap enter to continue.
Second installation method: Download and configure
Run the following command:
$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz $ tar -xvf Python-3.6.3.tgz $cd Python-3.6.3 $ sudo ./configure --enable-optimizations
If the configuration above does not return any error, run the commands below to finish your installation of Python 3.6 with this command:
$ sudo make -j8 $ sudo make install
Step 5: Update The Repositories
To update the repositories, run the command below:
update the repositories apt-getupdate
Step 6: Check The Python 3.6 You’ve Installed On Ubuntu 16.04
As soon as you are done with the installment, you can check the version of Python you’ve installed by carrying out the commands below:
# python3.6-V Python 3.6.3
Step 7: Create Virtualenv Using Python 3.6 (non-compulsory)
This step is non-compulsory. Because you now have more than one version of Python 3 on your Ubuntu and since you need only Python 3.6 for your programming, the recommended practice is to generate a virtual environment with the use of Python 3.6. To do this, run the commands below:
$ sudo pip3 install virtualenv
$ virtualenv -p /usr/bin/python3.6 ~/virtualenvs/venv_devopspy $ source virtualenvs/venv_devopspy/bin/activate (venv_devopspy) nahmed@localhost:~$
Step 8: Install Python 3.6 In Ubuntu 16.10 and 17.04
The recent Ubuntu 17.10 has Python 3.6 by default. You can check it by running python 3 commands. Python 3.6 is commonly present in the Universe repository on Ubuntu 16.10 and 17.04. You can easily install it through apt using the command below:
To do this, run the command below:
$ sudo apt-get update $ sudo apt-get install python3.6
To check the entire list of Python binaries you have on your system, execute the ls-command below:
$ ls -l /usr/bin/python*
You can As well verify the version of Python installed with the use of the command below:
$ python -V
To make use of Python 3.6, call the command below:
To close the Python interpreter, key-in the command below and key-in Enter.
There you have it! This tutorial has provided you with the step by step tips you need to install the latest Python 3.6 in Ubuntu 14.04, 16.04, 16.10 and 17.04 through the APT package manager. Feel free to give us a shout if there is anything you aren’t clear about. Also, do not hesitate to leave your comments.
Check out these top 3 Linux hosting services