Skip to main content

10 Set up Python for Weaviate

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

Image alt

Install Python

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.11.8. If you Python 3.8 or higher installed, you can skip the remainder of this section.

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.

Set up a 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.

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.

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. If you are already using one of these tools, you can use them instead of venv.

Install the Weaviate client

Now, you can install the Weaviate client library, which will make it much easier to interact with Weaviate using Python.

Activate your virtual environment, then install the Weaviate client with:

pip install weaviate-client

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.5.4.

Congratulations, you are now set up to use Weaviate with Python and the Weaviate Python client library!

Questions and feedback

If you have any questions or feedback, let us know in our user forum.