Difference between revisions of "Python on the CS Webservers"

Line 5: Line 5:
 
== Python Versions ==
 
== Python Versions ==
  
The webservers have both Python 3 and Python 2 available. <!-- As of December 2020, they are specifically running Python versions 3.6 and 2.6. -->
+
The webservers have both Python 3 and Python 2 available.
  
The default Python version (what you get when you run the <code>python</code> program) on our ugrad webserver ([https://ugrad.cs.jhu.edu ugrad.cs.jhu.edu]) is Python 3.  If you want Python 2, you must specify it explicitly by using <code>python2</code> at the top of your program.
+
The default Python version (what you get when you run the <code>python</code> program) is Python 3.  If you want Python 2, you must specify it explicitly by using <code>python2</code> at the top of your program.
  
The default Python version on the grad webserver ([https://www.cs.jhu.edu www.cs.jhu.edu]) is Python 2, though it will be changing to Python 3 in January 2021 (and is Python 3 already on the testing webserver [https://web2.cs.jhu.edu web2.cs.jhu.edu]).  You should specify the Python version in your programs by explicitly using either the <code>python2</code> or <code>python3</code> program.
+
It's good practice to explicitly use <code>python3</code> when you intend to use Python 3.  Using <code>python</code> by itself is only recommended [https://www.python.org/dev/peps/pep-0394/ in a handful of situations] that mostly don't apply to our webservers.
  
 
== Python Packages ==
 
== Python Packages ==
  
 
The set of Python packages installed on the webservers is fairly minimal.  If you need a package that's not installed, you should first try installing it yourself into your home directory, using our [[Python on the CS Linux Clients#pip|pip instructions]].  If that does not work, you can contact us at [mailto:support@cs.jhu.edu support@cs.jhu.edu] for assistance, but be aware that we are not be able to install every requested package.
 
The set of Python packages installed on the webservers is fairly minimal.  If you need a package that's not installed, you should first try installing it yourself into your home directory, using our [[Python on the CS Linux Clients#pip|pip instructions]].  If that does not work, you can contact us at [mailto:support@cs.jhu.edu support@cs.jhu.edu] for assistance, but be aware that we are not be able to install every requested package.
 +
 +
== Deployment Options ==
 +
 +
For technical reasons, we do not support WSGI.  You will have to run your Python programs as either CGI or FastCGI programs.  (Most major Python web frameworks support FastCGI deployment; see their documentation for details.)
  
 
[[Category:Webpages and Webservices]]
 
[[Category:Webpages and Webservices]]

Revision as of 20:32, 1 July 2021

Python is supported as a CGI program on the CS Department webservers, but there are a few things you should know about it.

You may also want to read about Python on the CS Linux Clients.

Python Versions

The webservers have both Python 3 and Python 2 available.

The default Python version (what you get when you run the python program) is Python 3. If you want Python 2, you must specify it explicitly by using python2 at the top of your program.

It's good practice to explicitly use python3 when you intend to use Python 3. Using python by itself is only recommended in a handful of situations that mostly don't apply to our webservers.

Python Packages

The set of Python packages installed on the webservers is fairly minimal. If you need a package that's not installed, you should first try installing it yourself into your home directory, using our pip instructions. If that does not work, you can contact us at support@cs.jhu.edu for assistance, but be aware that we are not be able to install every requested package.

Deployment Options

For technical reasons, we do not support WSGI. You will have to run your Python programs as either CGI or FastCGI programs. (Most major Python web frameworks support FastCGI deployment; see their documentation for details.)