Prepare your Python Virtual Environment
To manage Python packages for your Viam application, it is recommended that you use a virtual environment, or
By using a
venv, you can install Python packages like Viam’s client SDK within a virtual environment, avoiding conflicts with other projects or your system.
Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your Viam client application.
Setup your project
First, create a directory for your project.
For example, name your directory
mkdir viam-python cd viam-python
Create and Activate a Virtual Environment
In the project directory, create and activate a virtual environment for Python to run in.
python3 -m venv viam-env source viam-env/bin/activate
(viam-env) prepends the commands in your terminal window to indicate the Python packages being used are from this particular environment.
You can exit this environment by running
Inside the activated
viam-env python environment, you can now install the Viam SDK:
pip3 install viam-sdk
This installs Viam and all required dependencies.
If you need to install your own requirements, also install them in this virtual environment.
To make your required packages easier to install in the future, you can also create a
pip3 install -r requirements.txt.
Setup your IDE
If you would like to be able to use the environment you created with your IDE, point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter.
The following steps are for VS Code. If you’re not using VS Code, please read your IDE’s documentation on selecting python interpreters.
- Open the
viam-pythondirectory in VS Code
- Open the Command Palette (using
⇧⌘Por through the menus View -> Command Palette)
- Select the command
Python: Select Interpreter. There, you should see all the interpreters available to you. You’re looking for the on you just made:
viam-env. It will look something like:
Python 3.XX.X ('viam-env': venv) ./viam-env/bin/python. If you don’t see it, click the
Refreshicon on the top right of the Command Palette. Select the
Your IDE will now recognize all packages installed in this environment.
You are now ready to start using Viam’s Python SDK!
Have questions, or want to meet other people working on robots? Join our Community Discord.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better: