Python Scripts not running in cPanel- Showing code
Python is a high-level programming language. There are users complaining the script shows itself up rather than executing. I am now explaining how to fix this issue.
To test this we must have a test Python code. Here is the hello world test code:
print “Content-type: text/html\n\n”
print “Hello world!!”
In cPanel, by-default the Python is located under “/usr/bin/python“. If there was any change, you can check the location by running the following command:
The python script must be created with the extension “.py”
If you have shell access you can create it by using your favorite file editor (vi, nano etc). You can use the file manager feature, if you have only the cPanel access. Or else the file can be locally created and uploaded using FTP also
Ensure the owner:group is set correctly as the user who is to execute the command Also, it should have executable permission!!
Still the script shows up code, the handler must be missing 🙂
Add AddHandler in .htacces file!!
AddHandler cgi-script .py
You should be good to go now