I cannot get Centos to use python3. Installed python3 via yum, it has created v3.6. With this test program it works only if I specify the v2 version.
#!/usr/bin/python3
print "Content-type:text/html\r\n\r\n"
print "test"
#!/usr/bin/python3 - internal server error 500
#!/usr/bin/python3.6 - internal server error 500
#!/usr/bin/env python3 - internal server error 500
#!/usr/bin/python2.7 - runs
#!/usr/bin/python - runs
#!/usr/bin/env python - runs
If I type python3 at a prompt then it opens the python system, so the links are clearly working.
$ python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
The links all appear to be correct
$ cd /usr/bin
$ ls -al pyt*
lrwxrwxrwx 1 root root 16 Oct 15 23:27 python -> /usr/bin/python2
lrwxrwxrwx 1 root root 18 Oct 15 23:27 python2 -> /usr/bin/python2.7
-rwxr-xr-x 1 root root 7144 Nov 16 2020 python2.7
-rwxr-xr-x 1 root root 1835 Nov 16 2020 python2.7-config
lrwxrwxrwx 1 root root 16 Oct 15 22:31 python2-config -> pythonl2.7-config
lrwxrwxrwx 1 root root 9 Oct 15 23:48 python3 -> python3.6
-rwxr-xr-x 2 root root 11328 Nov 16 2020 python3.6
-rwxr-xr-x 2 root root 11328 Nov 16 2020 python3.6m
lrwxrwxrwx 1 root root 14 Oct 15 22:31 python-config -> python2-config
There is only one installation of python 3 (and another of python2.7) $ which python3 /usr/bin/python3
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/manningk/.local/bin:/home/manningk/bin
File created from scratch in VI to avoid problems with line endings. Have uninstalled/reinstalled python3 via yum.
File is executable -rwxr-xr-x 1 apache apache 32 Oct 16 20:39 test2.py
Honestly, I'm stuck. Is it a simple typo I can't see or what? Thanks