Choosing a version of Python
You can choose among multiple versions of Python:
|Silk platform||Python version||Command-line path|
If you need to switch Python versions, you can do so by creating or editing
.silk.ini file (for example
~/www-root/.silk.ini) and adding the
version to the
[python] version = 3.6
Valid version choices are
default, any of the versions listed in the table
newest (which provides the newest available on the system).
Silk platform version 1
Silk will execute scripts ending in .py within a Python FCGI handler that runs within the WSGI model. Scripts will be dynamically loaded as modules on the first request, and their 'request_handler' attribute should be set to the instance of a function implementing the start_response() callable.
Example WSGI script
def my_handler(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield "Hello World\n" for k, v in sorted(environ.items()): yield "%s: %s\n" % (k, v) request_handler = my_handler
The environment variable
wsgi_max_requests can be set to cause the FCGI wrapper to reload your Python script (module) every N requests. During development, you can set this to something very low to see incremental changes as you work. Otherwise, the FCGI wrapper will cache your code for
For example, in your .htaccess file:
SetEnv wsgi_max_requests 10
Silk platform version 2
Python applications use Phusion Passenger
as an app server. You can run an application by placing the following in an
.htaccess file in your
PassengerAppType wsgi PassengerStartupFile wsgi.py PassengerAppRoot /users/m/y/mynetid/www-root PassengerPython /usr/bin/python
PassengerStartupFile should be the script that launches your application.
PassengerAppRoot should be the full path to the directory where your
application's startup file is located.
PassengerPython should be the full path to your preferred version of Python.
An application needs to be restarted for code changes to take effect. You can do this by killing the current application process:
[myusername@silk21 ~]$ pkill -u myusername -f wsgi-loader
Your application will relaunch the next time it is requested from a web browser.
Python modules are managed using the
You can see which modules are currently installed by typing
pip list, or see
which you have installed yourself with
pip list --user.
Additional modules can be installed by typing
pip install --user <modulename>,
which will place them in your home directory, under
Scripts or commands included with a module are placed in
can either be run directly from there or added to your PATH by adding a line
such as the following to