How to setup environment manager environments to work with tutorials

AI SDK How-To

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

You can use your preferred Python environment manager to create the Python environment. We show here the commands for Python venv, taking end-to-end tutorial Image Classification as an example. For other end-to-end tutorials, you have to substitute the name image_classification as described in the tutorial's README.

NOTICE

It is strongly recommended to create independent environments for end-to-end tutorials, and also for Jupyter Lab.

Prerequisites

Before proceeding, ensure that you have the necessary prerequisites for using the AI SDK. In addition to the standard requirements, you will need a few extra Python dependencies specific to your use case, as well as an IPyKernel for executing code cells in Jupyter notebooks.

The following steps assume that you have already installed the chosen version of Python. You will begin by creating virtual environments for various tasks.

Getting AI SDK Tutorials

AI SDK Tutorials can be downloaded from the following sources:

Prepare environments

To execute Jupyter notebooks, both of the notebook editors will require an IPykernel installed, which is connected to a Python environment.

You can use your preferred Python environment manager to create the Python environment. We show here the commands for Python venv, taking end-to-end tutorial Image Classification as an example. For other end-to-end tutorials, you have to substitute the name image_classification as described in the tutorial's README.

NOTICE

It is strongly recommended to create independent environments for end-to-end tutorials, and also for Jupyter Lab.

Create a Python virtual environment and activate it

This method requires a preinstalled Python 3.10 or 3.11 runtime.

cd ~/ai-sdk-tutorials/e2e-tutorials/image_classification
python -m venv ./venv
sh ./venv/bin/activate

Once you executed the commands above, you will have the folder .venv created and activated .Now every new installation of a Python package will be accessible in this environment, or you can deactivate it.

Install requirements for an end-to-end tutorial

Next, step into the image_classification folder and install the ipykernel package along with the end-to-end tutorial's dependencies and with AI SDK.

These packages must be installed at the same time for pip's dependency resolution to work correctly.

cd ~/ai-sdk-tutorials/e2e-tutorials/image_classification
pip install ipykernel -r requirements.txt -f ~/ai-sdk-core

Please note that by default, pip will install the newest available version of required packages that are compatible with the SDK and the end-to-end tutorial. If you want to make sure to use the versions that are listed in Readme_OSS, you can apply the appropriate constraint during installation as follows:

cd ~/tutorials/e2e-tutorials/image_classification
pip install ipykernel -r requirements.txt -c constraints.txt -f ~/ai-sdk-core

Once the environment is created and activated, you need to register it as an interactive Python kernel so that it becomes available in your notebook editor. This is can be achieved with the following command:

python -m ipykernel install --user --name image_classification --display-name "Python (image_classification)"