Hey Everyone! The main reason is to help those who are having difficulties learning. Today I'll be installing Python on the ubuntu 18.04 LTS version.
Installing Python 3.7 on Ubuntu with apt
is a relatively straightforward process and will only take a few minutes:
1. Start by updating the packages list and installing the prerequisites:
# sudo apt update
# sudo apt install software-properties-common
2. Next, add the deadsnakes PPA to your sources list:
# sudo add-apt-repository ppa:deadsnakes/ppa
When prompted press Enter
to continue:
Press [ENTER] to continue or Ctrl-c to cancel adding it.
3. Once the repository is enabled, install Python 3.7 with:
# sudo apt install python3.7
4.At this point, Python 3.7 is installed on your Ubuntu system and ready to be used. You can verify it by typing:
# python3.7 --version
# Python 3.7.3
Installing Python 3.7 on Ubuntu from Source
In this section we’ll show you how to download and compile Python 3.7:
1.First, update the packages list and install the packages necessary to build Python source:
# sudo apt update
# sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
2.Download the latest release’s source code from the Python download page using the following wget command:
# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz4
3.Once the download is complete, extract the gzipped tarball:
# tar -xf Python-3.7.4.tgz
4.Next, navigate to the Python source directory and run the configure script which will perform a number of checks to make sure all of the dependencies on your system are present:
# cd Python-3.7.4
# ./configure --enable-optimizations
The --enable-optimizations option will optimize the Python binary by running multiple tests. This makes the build process slower.
For faster build time, modify the -j flag according to your processor. If you do not know the number of cores your processor, you can find it by typing nproc
in terminal. The system used in this guide has 4 cores, so we are using the -j4 flag.
5. Start the Python build process using make
# make -j 4
6. When the build is done, install the Python binaries by running the following command:
# sudo make altinstall
Do not use the standard make install as it will overwrite the default system python3 binary.
7. That’s it. Python 3.7 has been installed and ready to be used. Verify it by typing:
# python3.7 --version
The output will show the Python version:
# Python 3.7.4
You have installed Python 3.7 on your Ubuntu 18.04 machine and you can start developing your Python 3 project.
You can follow me on @tahaadotdev
at Instagram, twitter!!
Happy Coding!!
Top comments (0)