WARNING: you are on the master branch, please refer to the docs on the branch that matches your
You can install your required PyPI packages and import them in your Python files using pip. Cortex looks for a
requirements.txt file in the top level Cortex project directory (i.e. the directory which contains
./iris-classifier/├── cortex.yaml├── predictor.py├── ...└── requirements.txt
If you want to use
conda to install your python packages, see the Conda section below.
Note that some packages are pre-installed by default (see "pre-installed packages" for your Predictor type in the Predictor documentation).
To install packages from a private PyPI index, create a
pip.conf inside the same directory as
requirements.txt, and add the following contents:
[global]extra-index-url = https://<username>:<password>@<my-private-index>.com/pip
In same directory, create a
dependencies.sh script and add the following contents:
cp pip.conf /etc/pip.conf
You may now add packages to
requirements.txt which are found in the private index.
You can also install public/private packages from git registries (such as GitHub) by adding them to
requirements.txt. Here's an example for GitHub:
# requirements.txt# public accessgit+https://github.com/<username>/<repo name>.git@<tag or branch name>#egg=<package name># private accessgit+https://<personal access token>@github.com/<username>/<repo name>.git@<tag or branch name>#egg=<package name>
On GitHub, you can generate a personal access token by following these steps.
Python packages can also be installed by providing a
setup.py that describes your project's modules. Here's an example directory structure:
./iris-classifier/├── cortex.yaml├── predictor.py├── ...├── mypkg│ └── __init__.py├── requirements.txt└── setup.py
In this case,
requirements.txt will have this form:
Cortex supports installing Conda packages. We recommend only using Conda when your required packages are not available in PyPI. Cortex looks for a
conda-packages.txt file in the top level Cortex project directory (i.e. the directory which contains
./iris-classifier/├── cortex.yaml├── predictor.py├── ...└── conda-packages.txt
conda-packages.txt file follows the format of
conda list --export. Each line of
conda-packages.txt should follow this pattern:
Here's an example of
In situations where both
conda-packages.txt are provided, Cortex installs Conda packages in
conda-packages.txt followed by PyPI packages in
requirements.txt. Conda and Pip package managers install packages and dependencies independently. You may run into situations where Conda and pip package managers install different versions of the same package because they install and resolve dependencies independently from one another. To resolve package version conflicts, it may be in your best interest to specify their exact versions in
The current version of Python is
3.6.9. Updating Python to a different version is possible with Conda, but there are no guarantees that Cortex's web server will continue functioning correctly. If there's a change in Python's version, the necessary core packages for the web server will be reinstalled. If you are using a custom base image, any other Python packages that are built in to the image won't be accessible at runtime.
Check the best practices on using