Skip to main content

Development environment setup

Follow this short guide to make sure that you are set up to use Weaviate with the Python client.

Python

For experienced Python developers

If you are an experienced Python developer and already have a suitable Python environment set up, you can skip to the Install the required packages section.

Is Python installed?

Open a terminal window (e.g. bash, zsh, Windows PowerShell, Windows Terminal), and run:

python --version

If that did not work, you may need to use python3 instead of python:

python3 --version

If you have Python installed, you should see a response like Python 3.10.16. If so, you can skip to Set up a virtual environment section.

Which Python version to use

Weaviate Academy is built with Python 3.10. While it should work with Python 3.10 or later, if you encounter any issues, we recommend trying the specified version.

Install Python

To install, follow the instructions for your system on Python.org.

Once you have Python installed, check the version again to confirm that you have a recommended version installed.

Advanced option: pyenv

Another good way to install Python is to install pyenv. This will allow you to manage multiple versions of Python on your system. You can find instructions on how to install pyenv here.

Environment variables

You will see code examples in Weaviate Academy that make use of environment variables. These are typically used to store sensitive information, such as API keys, that you should not expose in your code.

In a Unix-based system, you can set environment variables in the terminal like this:

export WEAVIATE_URL="your_weaviate_url"
export WEAVIATE_API_KEY="your_weaviate_api_key"

Or by configuring them in your shell's configuration file (e.g. .bashrc, .zshrc, .bash_profile).

If you are new to environment variables, this beginner's guide or this Wikipedia entry may be helpful.

Virtual environment

A virtual environment allows you to isolate various Python projects from each other. This is useful because it allows you to install dependencies for each project without affecting the others.

Virtual environments

Virtual environments are very useful. If you would like to learn more, try this tutorial on FreeCodeCamp or this article on RealPython, which goes a little more in-depth.


Additionally, there are many other environment management tools available, such as conda, pipenv, and poetry. Our favorite is uv, which is quickly gaining popularity. If you are already using one of these tools, you can use them instead of venv.

Create a virtual environment

We recommend using venv to create a virtual environment. Navigate to your project directory (e.g. cd PATH/TO/PROJECT), and run:

python -m venv .venv

Or, if python3 is your Python command:

python3 -m venv .venv

This will create a virtual environment in a directory called .venv in your project directory.

Activate the virtual environment

Each virtual environment can be 'activated' and 'deactivated'. When activated, the Python commands you run will use the Python version and libraries installed in the virtual environment.

To activate the virtual environment, go to your project directory and run:

source .venv/bin/activate

Or, if you are using Windows:

.venv\Scripts\activate.bat

You can check if the virtual environment is activated by running:

which python

Or, if you are using Windows, run Get-Command python (PowerShell) or where python (Command Prompt).

If the virtual environment is activated, you should see a path that points to the .venv directory.

Install the required packages

Weaviate Academy's Python courses uses the Weaviate client library, which makes it easy to interact with Weaviate using Python.

This course also requires the following Python modules:

  • pandas
  • requests
  • tqdm

Activate your virtual environment, then install the required packages. Here are example commands for both uv and pip:

uv add weaviate-client pandas requests tqdm

Confirm the installation

To confirm that the Weaviate client is installed, run the following Python code:

import weaviate

print(f"Your Weaviate client library version is: {weaviate.__version__}.")

You should see an output like:

Your Weaviate client library version is: 4.16.9.
What's next?

Great, you are now set up to use Weaviate with Python and the Weaviate Python client library.

Next, we'll show you how to create a Weaviate instance and connect to it.

Login to track your progress