Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

What versions of Python can I use with Anvil?

Are you new here?

Anvil is a tool for building full-stack web apps with nothing but Python and a drag-and-drop designer. Learn more on our website, or sign up and try it yourself -- it's free!

Python versions on client and server

There are two types of Python code in Anvil: Server Modules (which run on the Anvil server) and Form code (which runs in the user’s web browser).

Server Modules

Server Modules run on Anvil’s servers (you don’t have to set up your own servers – just write the code and call it!). The users of your app can’t see or change the code in your Server Modules.

You can choose to run your app’s Server Modules with Python 2.7 or 3.7, if you’re using a paid account:

Choose between Python 2.7 and 3.7

Free Plan users must use the Restricted Python 2 environment, which has fewer libraries available to import. (Free Plan users can still use the Uplink, though!)

Form (browser) code

Form code in Anvil is compiled to Javascript, using the Skulpt compiler. Skulpt supports “approximately Python 2.7”, although there are some operations and libraries that are not supported. (For example, it doesn’t make sense to access a filesystem in the web browser – instead, we use Media objects to represent binary data.)

The user of an app can see the source code for your Forms (via “View Source” in their web browser). The can also change how forms behave in your browser – so don’t rely on code in your Forms to enforce security! See our security documentation for more information.

Modules: Using code in both environments

Sometimes you want to write library code that can be used on the server and in the browser. To do this, create a Module. You can import Module code from the client or the server.

Module code is loaded in the same environment as whatever is importing it. If you import a Module from a Form, it will be loaded in Python 2; if you import from server code, it will be loaded in whichever Python version you have chosen.

The user of an app can see source code for your Modules. They can also manipulate how Module code behaves in the browser. (Of course, this doesn’t change how Modules behave when they’re imported by Server Modules and running on Anvil’s servers.)

If use the Uplink to connect your app to code running outside Anvil, that code runs in whatever version of Python you are using with the Uplink. The user of an app cannot see or modify Uplink code.

Reference documentation

For more details, you can read our reference documentation:

Reference documentation: The Anvil Runtime