Python Venv Activator
A VS Code extension that simplifies Python virtual environment management. With a single command, you can create and activate virtual environments without leaving your editor.
Features
- One-click activation of Python virtual environments
- Smart detection of existing environments (venv, .venv, etc.)
- Auto-detection of environments with names ending in "venv" or "env"
- Create new environments if none exist
- Properly updates terminal prompt to show the active environment
- Works reliably on Windows, macOS, and Linux
Installation
From VSIX file
- Download the
.vsix
file from the latest release
- In VS Code, go to Extensions view (Ctrl+Shift+X)
- Click the "..." (More Actions) button at the top of the Extensions view
- Select "Install from VSIX..." and choose the downloaded file
Building from source
# Clone the repository
git clone https://github.com/yourusername/venv-activate.git
cd venv-activator
# Install dependencies
npm install
# Compile the extension
npm run compile
# Package the extension
npx vsce package
# Install the generated .vsix file
code --install-extension venv-activator-0.1.0.vsix
Usage
- Open a workspace containing a Python project
- Press
Ctrl+Shift+P
(or Cmd+Shift+P
on macOS) to open the Command Palette
- Type "Activate Venv" and select the command
The extension will:
- Look for existing virtual environments in your workspace
- If found, activate it in a new terminal with the environment name in the prompt
- If multiple environments are found, let you choose which one to activate
- If no environment is found, offer to create a new one
You can also use the keyboard shortcut: Ctrl+Shift+A
(or Cmd+Shift+A
on macOS)
How It Works
When you run the "Activate Venv" command, the extension:
- Searches your workspace for directories named:
venv
, .venv
, env
, .env
, virtualenv
, etc.
- Also detects any directory ending with "venv" or "env" (e.g.,
my-project-venv
, backend-env
)
- If no environment is found, offers to create a new one or let you select an existing one
- Creates a dedicated terminal with the environment name in the prompt
- Activates the environment and shows confirmation
Windows Terminal Display
On Windows, the extension ensures the virtual environment name is displayed in the terminal prompt by:
- Setting the prompt format with
prompt (venv) $P$G
- Running the activation script
venv\Scripts\activate
- Showing the Python executable path to confirm activation
Configuration
This extension has no configurable settings yet. Future versions may include options for:
- Custom virtual environment locations
- Default environment name
- Custom terminal commands
Requirements
- VS Code 1.60.0 or higher
- Python installed on your system
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
License
This extension is licensed under the MIT License.