To install dependencies, you can add them to a
requirements.txtfile, and Airplane will
pip installfrom it when deploying.
You should place this
requirements.txtfile either next to your script or in a parent directory. The closest directory containing
requirements.txtbecomes the root of your project.
If you want to import from other modules, ensure that the
requirements.txtis placed in a place where the other modules will get included in the project:
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
createVenvsetting via your
airplane.yaml, Airplane will automatically create a virtual environment for you:
Virtual environments are created within a
.venvfolder 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.txtwill be automatically installed into the virtual environment.
To add dependencies, use the virtual environment's
shCopied1$ .venv/bin/pip install -r requirements.txt <package>
Alternatively, you can manually activate the virtual environment and then use
If you run into issues related to virtual environments, you can safely delete the
.venvfolder 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-projectfor Poetry or
PIPENV_VENV_IN_PROJECTfor pipenv). As long as the virtual environment is created within the task's root directory, Airplane will automatically activate it.
If you need a custom pip configuration, you can also create a
pip.conffile in the same directory as the
requirements.txtfile, and Airplane will use that
pip.conffile when executing