Install Python 3 in cPanel Server
This blog explains how to install Python 3 in cPanel server. As you know, cPanel comes with Python 2.X as the mentioned version of Python is used for Mailman and Yum. Hence, we can’t upgrade the Python version as it may break the current cPanel setup.
In this post, I am describing how to install Python 3 alongside with the existing Python version in cPanel server. Therefore, you can use the tools which require Python 3 on your cPanel server.
As we are installing the latest Python from source, we need to install the development tools and the libraries for the proper functioning of the lastest Python version.
yum update yum groupinstall "development tools" yum install tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel readline-devel lib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel libffi-devel
Once the prerequisites installed, we can go ahead and install Python 3
Install Python 3 from Source
Download the latest version of Python from here: https://www.python.org/ftp/python/
cd /usr/local/src wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz tar xzf Python-3.7.2.tgz cd Python-* ./configure --prefix=/usr/local/python3.7 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" make make altinstall
Please make sure that you run make altinstall instead of make install. The make install command will break the existing Python installation.
To get Python 3.7 globally upon login, you need to update the library path like below:
Create a file python3.7.sh:
Add the following into it:
PATH=$PATH:/usr/local/python3.7/bin export PATH
Also, create another file opt-python3.6.conf
Add the following into it:
Run the following commands to create the necessary links and cache to the most recent shared libraries found in the directories specified on the command line.
ldconfig source /etc/profile.d/python3.7.sh
It will complete the Python 3 setup and you can verify the both Python installation using the following commands:
Base Python installation:
[root@grepit ~]# python -V Python 2.7.5 [root@grepit ~]#
Python 3.7 installation:
[root@grepit ~]# python3.7 -V Python 3.7.2 [root@grepit ~]#
- Disable Outgoing email of a cPanel Account
- Enabling PHP-FPM forces disable_functions in cPanel
- Softaculous Showing Blank Page in cPanel WHM
- How to Combine Apache Access Logs in cPanel
- How to increase tmp directory size in cPanel
- How to install SimpleHelp on cPanel or Linux
If you like the post Understanding top Command and wish to receive more articles from us, please like our FB page: GrepItOut
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at email@example.com