Install python 3.8 centos 7

You must install Python 3.8 on all hosts after installing Cloudera Manager and before adding the services to your cluster.

Install the necessary developer tools such as gcc and make on your system.

Install the following packages before installing Python 3.8:

  • openssl-devel
  • bzip2-devel
  • libffi-devel
  • zlib-devel
yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel -y

  1. SSH into the host system as a root user.
  2. Download Python 3.8 and decompress the package by running the following commands:

    cd /opt
    curl -O //www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz

    tar -zxvf Python-3.8.12.tgz

  3. Change directory to where you decompressed the Python 3.8 package:
  4. Install Python 3.8 as follows:

    ./configure --enable-shared --prefix=[***CUSTOM-INSTALL-PATH***]

    The --enabled-shared option is used to build a shared library instead of a static library.

  5. Build Python 3.8 as follows:
    1. Run the make command to compile the files:
    2. Run the following command to put the compiled files in the default location or in the custom location that you specified using the --prefix option:
    3. Copy the shared compiled library files [libpython3.8.so] to the /lib64/ directory:

      cp --no-clobber ./libpython3.8.so* /lib64/

      The --no-clobber option is used to prevent overwriting files.

    4. Change the permissions of the libpython3.8.so files as follows:

      chmod 755 /lib64/libpython3.8.so*

    If you see an error such as error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory, then run the following command:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/

[For Hue] If you have installed Python 3.8 at a custom location, then you must append the custom path in separated by colon [:] as follows:

Key: PATH

Value: [***CUSTOM-INSTALL-PATH***]:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

The CentOS 7 Linux distribution includes Python 2 by default. However, Python 2 is going to reach EOL on January 1, 2020. While some legacy applications might require access to Python 2 for various reasons, it’s vitally important to kick start new projects in Python 3.

In this tutorial, we are going to take a look at how to get up and running with Python 3 on a CentOS 7 server. Specifically, we will take a look at how to install Python 3 via the CentOS 7 package manager Yum as well as from source.

Pre-flight Check

  • These instructions are being performed on a Liquid Web Self-Managed Dedicated CentOS 7 server as the root user.
  • These instructions assume that your server has CentOS release 7.7.
  • We also have an awesome article on managing multiple versions of Python via Anaconda

Yum Installation

In CentOS 7 releases prior to 7.7, it was necessary to make Python 3 available for installation by setting up third-party repositories, such as the IUS repository, because the CentOS base repository did not provide a Python 3 package. Thankfully, as of CentOS 7.7, Python 3 is available in the base package repository!

Step 1: Update the environment

In order to make sure that we are working with the most up to date environment possible in terms of our packages, we can run the following command.

[root@centos7 ~]# yum update -y

Step 2: Install Python 3

Now that the environment is up to date, all we need do to install Python 3 is run the following command.

[root@centos7 ~]# yum install -y python3

That’s it! Python 3 is now installed! Another helpful idea to consider is that PIP, the Python package manager for Python 3, is installed alongside the Python 3 package, so we don’t have to worry about that as an additional installation step.

Verify Installation

In order to ensure that Python 3 is in fact installed and usable, we can drop into a Python 3 shell by running the following command.

[root@centos7 ~]# python3
Python 3.6.8 [default, Aug  7 2019, 17:28:10] 
[GCC 4.8.5 20150623 [Red Hat 4.8.5-39]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

You should see the version of Python 3 installed on your system as well as a change in the command prompt characters.

Source Installation

Installing Python 3 via the Yum package manager is by far the simplest way to get the job done. However, in some cases, you might want to have the most recent version of Python available and that’s where a source installation can come in handy.

Step 1: Setup the Environment

In order to install Python 3 from source, we are going to need to ensure that some prerequisite packages are installed on our system.

[root@centos7 ~]# yum install gcc openssl-devel bzip2-devel libffi-devel -y

Step 2: Download Python

Next, we need to grab the version of Python we want. The following command will pull down the latest stable version of Python 3.8 as of the writing of this article.

[root@centos7 ~]# curl -O //www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

Now we need to extract the file.

[root@centos7 ~]# tar -xzf Python-3.8.1.tgz

Step 3: Install Python 3

Now that it’s extracted, let’s change into the resultant directory.

[root@centos7 ~]# cd Python-3.8.1/

Next, we need to prepare to compile Python from source.

[root@centos7 Python-3.8.1]# ./configure --enable-optimizations

Finally, we are going to use the following command to finish off the installation, without replacing the default system Python on our system.

[root@centos7 Python-3.8.1]# make altinstall

Compiling code from source takes a little while, but once that’s finished, we can test out our new Python 3 version by running the following command.

[root@centos7 Python-3.8.1]# python3.8

Much like before when we installed Python 3.6 via Yum, we are dropped into a Python shell that outputs the version we are currently using.

Python 3.8.1 [default, Dec 27 2019, 17:12:30]
[GCC 4.8.5 20150623 [Red Hat 4.8.5-39]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Final Thoughts

Python has seen a continuous upward growth trend in the 21st century due to its flexibility in addressing both frontend and backend development goals. It also continues to provide, a strong cross-platform functionality when utilizing server clustering, along with the vast amount of available tools and libraries available that reduces the effort needed to write code and functions. Additionally, it has one of the industries’ strongest support community structures which ensures its continued success.

Because Python provides for the latest technologies with its constant growth and development in the field of Machine Learning and AI, we expect to see these advances continue to increase in the coming years.

How Can We Help?

Liquid Web delivers many of the newest technology private cloud hosting options that can allow you to take advantage of the latest methods and processes to grow your business well into the 21st century and beyond!

Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Experienced Hosting advisors to learn how you can apply these tools and techniques today!

How do I upgrade to Python 3.8 CentOS?

Install Python 3.8 on CentOS 7 / CentOS 8.
Step 1: Install Python Dependencies. As we'll install Python from source, let's install the packages required for Python installation. ... .
Step 2: Download latest Python 3.8 Archive. ... .
Step 3: Install Python 3.8 on CentOS 7 / CentOS 8. ... .
Step 4: Check Python 3.8 on CentOS 8 / CentOS 7..

How do I install a specific version of Python in CentOS 7?

How to Install Latest Version Of Python 3 on CentOS 7.
Access to a user account with sudo privileges. ... .
Verify you have successfully installed Python 3 with: python3 --version. ... .
Option 2: Install Python From Source Code. ... .
Next, use the wget command to download the desired Python version..

What version of Python does CentOS 7 use?

The CentOS 7 Linux distribution includes Python 2 by default. However, Python 2 is going to reach EOL on January 1, 2020. While some legacy applications might require access to Python 2 for various reasons, it's vitally important to kick start new projects in Python 3.

Does CentOS 7 have Python 3?

Python 3 is not installed by default in CentOS 7. Python 3 is not available in the official package repository of CentOS 7 as well. But we can add Inline Upstream Stable [IUS] package repository on CentOS 7 to install Python 3. The yum package repository cache should be updated.

Chủ Đề