So you are already familiar with Python and are wondering how to try some Generative AI projects on your PC.

You are aware that you need to to setup dependencies, but each project has a different approach.

And sometimes you are lucky and make it work…

Confused with Python Dependencies

But others you cant manage it properly.

Its time to learn how to manage Python AI Dependencies consistently:

  1. Install Python 🐍
python --version #this should work
  1. Get a F/OSS IDE
  2. Find a project that you want to try
  1. And now choose a Method

Top 2 Ways to Manage Python Dependencies

Venv’s

You are ready to start if this works:

python --version
pip --version

Create a Python Virtual Environment with:

python -m venv yourvenvname

Activate it and just use it like if it would be the main python installed in your computer:

# !python -m venv embedchain_venv
#Unix
#!source embedchain_venv/bin/activate
#Windows
#.\embedchain_venv\Scripts\activate

#deactivate

#Get-ExecutionPolicy
#Set-ExecutionPolicy RemoteSigned
#Set-ExecutionPolicy Restricted

pip install embedchain
pip show embedchain #check the installed version

This will show all the Python dependencies installed in the current environment:

pip list 
pip freeze > requirements.txt #put the current ones in a file

Install the requirements inside the Venv without fears of conflicts with:

pip install -r requirements.txt

You can add the venv to your gitignore as:

yourvenvname/

Containers

I Know, I love containers.

They are really helpful to completely pack an application, including the OS dependencies.

So using Docker to pack our Python AI app is just a particular case.

What do we need?

  1. You can use Docker or Podman
  2. And dont get afraid of the terminal, there are cool UI’s to Manage Docker Containers already:
  3. Artifacts for the Container Build

And ofc those are F/OSS Tools

Other Ways to Manage Py Dependencies

There are other ways to manage Python dependencies that you might find while exploring AI Projects.

Conda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
#wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh

chmod +x Miniconda3-latest-Linux-x86_64.sh
#chmod +x Miniforge3-Linux-aarch64.sh

./Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc

Now install packages in that conda env with:

conda --version

conda create --name myenv python=3.9 #conda create --name myenv
conda activate myenv
conda install package_name

#conda deactivate

Or with pip specifying the conda env:

python -m pip install -r requirements.txt #all at once

Pyenv

Just use PyEnv…

With Astral-sh

A new python package manager written in Rust.

Written in Rust, btw

apt install cargo
cargo install --git https://github.com/astral-sh/rye rye
#time cargo install --git https://github.com/astral-sh/rye rye

UV

pip install uv
uv venv  # Create a virtual environment at .venv.
# On macOS and Linux.
source .venv/bin/activate

# On Windows.
.venv\Scripts\activate
uv pip install streamlit
#uv pip install -r requirements.txt
conda --version
# conda create --name embedchain python=3.11
# conda activate embedchain
conda install numpy

FAQ

How to Install a Python Package from PyPi ⏬

The PyPI repository is essentially a giant ‘online store’ for Python code packages. When you use a library or framework in your Python project, you’re installing it from PyPI.

This ensures you have the right tools and avoids compatibility issues, making it crucial for managing dependencies in your projects.

By default, when you run pip install <package_name>, it fetches the package from the Python Package Index (PyPI).

PyPI serves as the ‘official repository’ for most third-party Python packages, making it the primary source for installing these dependencies.

Python IDE for AI Projects

  • VSCodium
flatpak install flathub com.vscodium.codium

How to install Python

  • From Ubuntu’s APT Repository:
sudo apt update
sudo apt install python3
python3 --version
  • Or With the PPA:
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12
python3 --version