Setting up an environment manager

AI SDK How-To

Product
AI Software Development Kit
Product Version
2.4.0
Language
en-US

When using multiple end-to-end tutorials and notebook editors, we recommend using an environment manager that can help you keeping those environments and the potentially conflicting requirements separate.Below you can find instructions for setting up Python venv environment manager.

Setting up Python venv

The builtin environment manager for Python requires the desired runtime version preinstalled on the system. You can invoke the environment creation and activation commands by explicitly specifying the path of the Python executable, or you can set up the most frequently used version as the system default.

First you need to add an extra package source to the system.

sudo add-apt-repository ppa:deadsnakes/ppa

Then you can install Python 3.10 and the venv environment manager. After that, you need to add the Python versions to the alternatives, with version 3.11 having a higher priority.

sudo apt install python3.10 python3.10-venv
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1

If you want to switch to an alternative version later, you can change the configuration with

sudo update-alternatives --config python

You can confirm whether the correct version is selected with python --version. The output should show:

Python 3.10.15