You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

Custom Python packages

To import a third-party package into your app’s Server Modules, you need to install it into that app’s server environment. Packages in Anvil are installed on a per-app basis, meaning that you can add only the necessary packages for each app.

Custom packages can be installed on all paid plans. To use custom packages in your apps on the Free Plan, consider using the Uplink.

Custom package installation is not available in the Classic Editor.

Available Python versions

Anvil provides multiple options for server environments. These can be selected from the drop-down menu under ‘Python version’, after navigating to ‘Python versions’ in your app’s Settings.

Selecting the Python 3.10 version for your app.
  • Python 3.10 (Beta) allows you to install custom packages into your app’s server environment.
  • Basic Python includes only the Standard library, and is the only option on the Free Plan.
  • Full Python 3 and Full Python 2 are the standard Anvil server environments with many packages already installed.

Available base environments

There are currently 4 Base Environments available. Choose a Base Environment that best suits your needs, to minimise the number of custom packages you will have to install yourself. For example, if you need the pandas package, we recommend starting from the Standard Base Environment, which already includes this package. If you also need tensorflow, choose the Machine Learning Base Environment.


This is a lightweight environment, containing only the necessary packages to run Anvil server code (such as, for example, ws4py).


This image contains everything from the Minimal environment, along with the following packages and all their dependencies:

Data Science

This image contains everything from the Standard environment, along with the following packages and all their dependencies:

Machine Learning

This image contains everything from the Data Science environment, along with the following packages and all their dependencies:

Adding packages

Packages can be added to your app’s server environment by entering a package name (as it appears in PyPI) in the left-hand box underneath the ‘Package’ section of the Python version settings. For each package, a version can be specified in the right-hand box, or left blank to use the latest version.

Adding the pymongo and beautifulsoup4 packages to the Standard base environment.

This display shows that pymongo==4.1.0 has been added to the Standard environment, and beautifulsoup4 is about to be added (with the latest version, by default).

To install packages from somewhere other than PyPI, see Advanced Options.

Build output

Once you add custom packages to the list, Anvil will install those packages to create a new server environment.

The Python Versions configuration page, with the 'Build output' section underneath the packages section expanded and highlighted.

Underneath the ‘Package’ installation section is a collapsible section which details the output of this process.

Possible errors

Anvil presents the output from pip’s install process directly. The two most common causes of build failures happen when a requested package could not be found, and when there is a conflict in dependency versions.

Package does not exist

ERROR: Could not find a version that satisfies the requirement `bad-package` (from versions: none)
ERROR: No matching distribution found for `bad-package`
Error: Build failed

This typically happens due to a typo. Double-check that the package you have requested is spelled correctly, and that the requested version (if any) is correct.

Conflicting dependencies

ERROR: Cannot install pymongo==4.1.0 and pymongo==4.1.1 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit
Error: Build failed

This happens when the dependencies you have requested have incompatible requirements. For help resolving this, visit pip’s dependency conflict management page.

Checking for Vulnerabilities

Once a server environment has been built, Anvil will use safety to check the installed dependencies of that environment for vulnerabilities. The output of this can be seen below the Build Output section.

If security vulnerabilities are detected, a button will appear, linking a report of which packages are affected.

The build output when installing `insecure-package`.

Advanced options

Editing your app’s requirements.txt directly

Anvil’s package mamagement uses pip, so packages can be installed from PyPI, a GitHub repository, or a URL using pip’s Requirements File Format. Your app’s requirements.txt file can also be edited directly, by clicking the link at the lower left of the Package section.

This will open up a text editor in which you can type your package list directly, just as you would into a requirements.txt file. This allows you to specify more nuance in your version dependencies, such as using the <= operator.

Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.