special sponsors

# Python

Python (opens new window) is a programming language that lets you work more quickly and integrate your systems more effectively.

You can easily add it to your Lando app by adding an entry to the services top-level config in your Landofile.

# Supported versions

# Legacy versions

You can still run these versions with Lando but for all intents and purposes they should be considered deprecated (e.g. YMMV and do not expect a ton of support if you have an issue).

# Patch versions

Not officially supported!

While we allow users to specify patch versions for this service, they are not officially supported, so if you use one, YMMV.

To use a patch version, you can do something as shown below:

    type: python:3.5.6

But make sure you use one of the available patch tags (opens new window) for the underlying image we are using.

# Configuration

Here are the configuration options, set to the default values, for this service. If you are unsure about where this goes or what this means, we highly recommend scanning the services documentation to get a good handle on how the magicks work.

Also note that options, in addition to the build steps and overrides that are available to every service, are shown below:

    type: python:3.7
    port: 80
    ssl: false
    command: tail -f /dev/null

# Specifying a command

Note that if you do not define a command for this service, it will effectively be a "cli" container (e.g. it will not serve or run an application by default but will be available to run python commands against).

If you want to actually launch a python application, consider setting the command to something as shown below:

    type: python
    command: /app/my-server.py

# Setting a port

While we assume your python service is running on port 80, we recognize that many python app's also run on port 8000 or otherwise. You can easily change our default to match whatever your app needs.

    type: python
    port: 8000

# Using SSL

Also note that ssl: true will only generate certs in the default locations. It is up to the user to use the certs and secure port correctly in their application like as in the python snippet below:

    type: python
    ssl: true
    port: 443
// Starting HTTPS server
httpsd = HTTPServer(('', 443), myHandler)
httpsd.socket = ssl.wrap_socket (httpsd.socket, server_side=True, certfile='/certs/cert.crt', keyfile='/certs/cert.key')
print('starting https server...')

# Path Considerations

Lando will set the PATH hierarchy for this service as follows:

  // Line directly below is your PYTHONUSERBASE

This is useful to note if you are not using absolute paths in any tooling routes and are getting the unexpected version of a particular utility.