I have a pristine Ubuntu (Ubuntu-24.04) distro running on WSL (see: WSL: Keeping a Pristine (Greenfield) Version of Your Distro). The blog presents the steps required to install Azure OpenAI SDK on this distro.
First, ensure packages are up to date:
sudo apt update
Ubuntu 24.04 blocks installing Python packages system-wide with pip to protect system tools. This means using pip system-wide to install packages will fail with an “externally-managed-environment” error. The correct way is to use a virtual environment (venv), which is a private sandbox for Python and its packages.
To enable venv on Ubuntu, install the package:
To make use of venv, create and activate a virtual environment where the source command activates the virtual environment:
The azure-ai-openai package isn’t publicly available on PyPI, so install the OpenAI Python SDK:
The -U option above ensures the version installed is upgrade to the latest.” → “The -U option above ensures the package is upgraded to the latest version.
Inside Python, paste the following to ensure access to the Azure OpenAI package:
Every time you access Azure OpenAI on this distro instance, the venv must be activated using the following:
No comments :
Post a Comment