Python version mismatch between shell and web server

Web hosting discussion, programming, and shared and dedicated servers.
2 posts Page 1 of 1
by mroeder » Sun Jun 10, 2018 12:30 am
A simple Python script to generate a web page worked perfectly under the shell account but failed with a 500 server error when I tried to see the web page though a browser (and thus the Apache server). It turned out that on shell.sonic.net, sys.version reports
2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

and on the webserver, sys.version reports
2.3.4 (#1, Nov 5 2004, 11:31:40) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)]

I was trying to use class string.Formatter, a feature that all the cool Python kids have been using since 2.6. When I used the older approach, it worked fine.

Is there a way to specify a newer version of Python in either environment? How do I find out what's installed?
by drew.phillips » Mon Jun 11, 2018 10:01 am
When running your Python CGI scripts on the web servers, you can get Python 2.6 by changing the shebang like to:

Code: Select all

#!/usr/bin/python2.6


Using that you'll get the following Python version instead of 2.3.

Code: Select all

2.6.5 (r265:79063, Jul 15 2010, 10:12:41) [GCC 3.3.4] 


For reference, this is mentioned here: https://wiki.sonic.net/wiki/CGI_FAQ_List#Python
Drew Phillips
Programmer / System Operations, Sonic.net
2 posts Page 1 of 1

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 422 on Sat May 26, 2012 5:28 am

Users browsing this forum: No registered users and 4 guests