Python dependencies

Install dependencies

To install dependencies, you can add them to a requirements.txt file, and Airplane will pip install from it when deploying.
You should place this requirements.txt file either next to your script or in a parent directory. The closest directory containing requirements.txt becomes the root of your project.
If you want to import from other modules, ensure that the requirements.txt is placed in a place where the other modules will get included in the project:
Copied
1
/
2
requirements.txt
3
pip.conf
4
airplane_tasks/
5
my_task.py
6
other_module/
7
__init__.py
8
other_submodule.py

Virtual environments

Virtual environments are a standardized isolation mechanism used to install dependencies without polluting your global Python environment. Using a virtual environment to develop Airplane tasks is recommended, but entirely optional.
If you enable the createVenv setting via your airplane.yaml, Airplane will automatically create a virtual environment for you:
airplane.yaml
Copied
1
python:
2
createVenv: true
Virtual environments are created within a .venv folder in your task's root directory (the folder containing your requirements.txt, else the folder containing your task's entrypoint). Upon creation, any dependencies in your requirements.txt will be automatically installed into the virtual environment.
To add dependencies, use the virtual environment's pip binary directly:
sh
Copied
1
$ .venv/bin/pip install -r requirements.txt <package>
Alternatively, you can manually activate the virtual environment and then use pip directly.
If you run into issues related to virtual environments, you can safely delete the .venv folder and Airplane will recreate it next time you execute a Python task.
Airplane is also compatible with virtual environments created by other tools, such as Poetry or pipenv. However, these tools tend to install virtual environments in a shared cache directory elsewhere on your file system. You will either need to manually activate this virtual environment before running airplane dev, or you can configure the tool to create virtual environments locally (e.g. setting virtualenvs.in-project for Poetry or PIPENV_VENV_IN_PROJECT for pipenv). As long as the virtual environment is created within the task's root directory, Airplane will automatically activate it.

Customize pip

If you need a custom pip configuration, you can also create a pip.conf file in the same directory as the requirements.txt file, and Airplane will use that pip.conf file when executing pip install.