Setting Up a Virtual Python Workspace#
To create a Python virtual environment using venv
, ensure that Python is installed on your system. You can download the installer from python.org. The AIM WebSocket API requires Python 3.8 or later.
On Windows, be sure to check the option to Add Python 3.x to PATH during installation. This may require administrative privileges.
On macOS and most Linux distributions, Python 3 is typically pre-installed, but it’s still a good idea to verify the version.
1. Create the Virtual Environment#
From within the aim_python_api
directory, run the following:
python -m venv venv
2. Activate the Virtual Environment#
From within the aim_ws_client
directory, run the appropriate command for your operating system:
Windows#
Powershell or Command Prompt:
venv\Scripts\activate
Git Bash (MINGW64) - not recommended:
source venv/Scripts/activate
macOS, Linux, and WSL#
source venv/bin/activate
Note: To ensure your virtual environment is activated automatically, you can add the activation command to your shell’s startup file (e.g., .bashrc
, .zshrc
).
Verify Shell Environment#
To verify that your shell environment is using the correct virtual environment, start a Python session by entering the REPL:
python
Then run the following commands:
import sys
print(sys.prefix)
The output should match the path to your virtual environment directory.
3. Install the Required Packages#
From within the aim_python_api
directory, run:
pip install -r requirements.txt
On macOS, if you encounter an error while installing pyaudio
, first install the portaudio
library using Homebrew, then try again:
brew install portaudio
pip install -r requirements.txt
On Debian/Ubuntu: Install portaudio19-dev
using apt, and then re-run pip install -r requirements.txt
:
sudo apt install portaudio19-dev
pip install -r requirements.txt
You can now run Python scripts on the connected robot.