This guide demonstrates how to install an app in a Python virtual environment, using aider-chat (an AI-powered coding assistant) as an example. We'll cover the process for both Windows and Linux systems.
Open your terminal (Command Prompt or PowerShell on Windows, Terminal on Linux) and run:
python -m venv aider-env
python3 -m venv aider-env
aider-env\Scripts\activate.bat
.\aider-env\Scripts\Activate.ps1
source aider-env/bin/activate
Your command prompt should now show (aider-env)
, indicating the virtual environment is active.
With the virtual environment activated, install the app:
pip install aider-chat
Check if the app is installed correctly:
aider --version
This should display the version of aider-chat you've installed.
Now you can use the app within your virtual environment. For example:
aider --help
This will display the help information for aider-chat.
When you're done, deactivate the virtual environment:
deactivate
To run the app from any directory without activating the virtual environment each time:
sudo tee /usr/local/bin/aider << EOF #!/bin/bash source /path/to/aider-env/bin/activate /path/to/aider-env/bin/aider "\$@" deactivate EOF
sudo chmod +x /usr/local/bin/aider
Replace /path/to/
with the actual path to your virtual environment.
aider.bat
in a directory that's in your system PATH (e.g., C:\Windows
):@echo off set VENV_PATH=C:\path\to\aider-env call %VENV_PATH%\Scripts\activate.bat %VENV_PATH%\Scripts\aider.exe %* call %VENV_PATH%\Scripts\deactivate.bat
C:\Windows\aider.bat
(or another directory in your PATH)C:\path\to\
with the actual path to your virtual environment
Now you can run aider
from any command prompt or PowerShell window.
You've now successfully installed an app (aider-chat in this example) in a virtual environment and made it accessible from anywhere in your system. This setup allows you to use the app without affecting your system-wide Python installation and provides convenient access from any directory.