skip to Main Content

My Cpanel host has 2 instances of Python.

Python 2.6 – /usr/bin/python

Python 3.6 – /usr/bin/python3.6

If I run this script:

#! /usr/bin/python

print "Content-type: text/htmlnn"
print "<html>Hello world!</html>"

It works!

But If it doesn’t work (Internal error 500) if I run:

#! /usr/bin/python3.6

print "Content-type: text/htmlnn"
print "<html>Hello world!</html>"

I know python 3.6 is installed and in the specified path, as you can see below:
enter image description here

WHEREIS
enter image description here

Thanks.

2

Answers


  1. Chosen as BEST ANSWER

    The problem seems to be the missing parentheses in the print function, it was python2 style and it was causing a 500 internal error.

    I changed to: print("Content-type: text/htmlnn") print("Hello world!")


  2. #! /usr/bin/python is a shebang line.

    A shebang line defines where the interpreter is located. In this case, the python3 interpreter is located in /usr/bin/python3.

    You may try using #!/usr/bin/python3 instead of #! /usr/bin/python3.6.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search