gnusys

Well-Known Member
Jan 18, 2013
53
13
58
cPanel Access Level
DataCenter Provider
I am facing an issue porting an existing python plugin for cPanel to python3 . It looks like the cPanel part of the plugin always run on python2.7 ( default python on Centos7) , irrespective of the fact that we add #!/usr/bin/python3 as the shebang line.

Now the WHM plugin part works pretty well and it respects the shebang line and works on python2 or python3

If I do on the script

Python:
import sys
print (sys.version)
it always shows Python version 2.7.5

I am porting the plugin to python3 because CentOS8 comes with python3 as default and I do not want to maintain 2 pieces of code for CentOS7 and CentOS8

Is this is a limitation imposed by cPanel and if yes is there a way to override/change the python version in cpaneld

NOTE: this is not about running a python app in apache, but a plugin in cpaneld ( the cpanel daemon)
 
Last edited by a moderator:

gnusys

Well-Known Member
Jan 18, 2013
53
13
58
cPanel Access Level
DataCenter Provider
Hi,

No. I tested this in CentOS8 and cPanel v92 and it is still using python2

Bash:
# 
# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

# /usr/local/cpanel/cpanel -V
92.0 (build 0)

# strings /usr/local/cpanel/cpsrvd|grep python
python
Could not locate a working python
/usr/bin/python2
$python_bin
Are you going to keep this like this or will there be a shift to python3 sometime?

Since cPanel itself does not rely on python, It would be great if there is some way the shebang line is honoured and users can choose the python interpreter for cpsrvd too
 

gnusys

Well-Known Member
Jan 18, 2013
53
13
58
cPanel Access Level
DataCenter Provider
From the RHEL8/CentOS-8 release notes

Dynamic programming languages, web and database servers
Python 3.6 is the default Python implementation in RHEL 8; limited support for Python 2.7 is provided. No version of Python is installed by default.

It seems CentOS-8 offers only limited support for python2 ( note it's being sunsetted for almost 1 year now). I do find many python2-xxx module RPM's missing in CentOS8

It could be installed via pip, but won't be a neat solution.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
Hey there, @gnusys - we have a nice thread with more details about Python3 here:


but the short answer is "not yet" :D