Skip to content

Install broken packages

When configuring your UbiOps environment you may encounter packages that do not install properly one way or another. E.g. because some packagesare conflicting with each other or have broken subdependencies. That means that you cannot install it by just using the requirements.txt file, and thus you need to manually configure it. This how-to will show you how to manually install such packages into your UbiOps environment package.

This how-to will cover the following steps:

  1. Preparing local environment
  2. Install Python 3 and other Linux packages
  3. Install your Python package
  4. Zip and upload the environment package

Use the correct local environment

You will first need to ensure being in a properly installed software environment for your package to work. UbiOps is using Linux Ubuntu 20.04 and 22.04, thus you will need to install the package for one of these OS's. Usually Ubuntu 22.04 works as it is the latest (as of February 2024) LTS Ubuntu version.

This can be done in multiple ways such as:

  • Having this version already installed on a local machine
  • Running a virtual machine with this OS
  • Running Windows Subsystem for Linux (WSL)
  • Spinning a container with this OS image

Install the needed Python version and other Linux packages

You need to install the required Python 3 version for your package. This can be done in a multitude of ways, you can install from APT or from source. We will cover the first one.

First, update the package repository:

sudo apt update

Then install the necessary version of Python 3:

sudo apt install python3.YOUR-VERSION

After it is done, you can check the installation:

python3 --version

Your UbiOps environment might also need other Linux packages that you placed in ubiops.yaml. In order to ensure you locally replicate the exact environment you want on UbiOps, you need to install these too locally using APT or other preferred method:

sudo apt update
sudo apt install YOUR-LINUX-PACKAGE

Install your Python package

First, create a new folder under your environment package.

mkdir PATH/TO/UBIOPS/ENV/PACKAGE/libraries

You will have to install your Python package in the newly created directory and pick the desired version using:

pip install --no-deps --target=PATH/TO/UBIOPS/ENV/PACKAGE/libraries YOUR-PYTHON-PACKAGE==YOUR-PACKAGE-VERSION

Here the --no-deps flag will only install the package without the necessary dependencies. However, you must ensure that all subdependencies are added to the requirements.txt file in the UbiOps environment package. The --target flag will install the package in the specified directory. Here it needs to be under libraries in the environment package. You can find more about the libraries folder here.

You can see the subdependencies of the package by doing the following command and looking under Requires:.

pip show YOUR-PYTHON-PACKAGE

Zip the directory of the package to the UbiOps environment

You can now zip the environment package and upload it when creating a new UbiOps environment, or when updating an environment revision.

zip -r environment_package.zip PATH/TO/UBIOPS/ENV_PACKAGE/

So that's it! We have gone through a full configuration of a Python package that cannot be installed normally in the environment package. There are more tutorials covering UbiOps environments here and here.