Skip to content

VSCodium Python Virtual Environment Setup

Overview

VSCodium is configured to automatically use the project's virtual environment located at .venv/.

Configuration

The .vscode/settings.json file contains the following Python-specific settings:

Python Interpreter

  • Default Interpreter Path: ${workspaceFolder}/.venv/bin/python
  • Python Path: ${workspaceFolder}/.venv/bin/python

These settings ensure VSCodium always uses the project's virtual environment.

Terminal Activation

  • Activate Environment: true - Auto-activates venv when opening integrated terminal
  • Activate in Current Terminal: true - Activates venv in already open terminals
  • Environment File: ${workspaceFolder}/.env.local - Loads environment variables

Testing Configuration

  • Pytest Enabled: true
  • Pytest Path: ${workspaceFolder}/.venv/bin/pytest
  • Test Discovery: Automatically discovers tests on save
  • Working Directory: Uses workspace folder as CWD

Analysis Paths

The following paths are added for Python analysis:

  • ${workspaceFolder}
  • ${workspaceFolder}/app
  • ${workspaceFolder}/services

Verification

To verify the setup is working correctly:

  1. Open VSCodium from the project root:
cd /home/paulb/tracker-restapi
vscodium .
  1. Check Python interpreter:
  2. Open Command Palette (Ctrl+Shift+P)
  3. Type "Python: Select Interpreter"
  4. Verify .venv/bin/python is selected

  5. Check terminal activation:

  6. Open a new integrated terminal (Ctrl+`)
  7. Verify the prompt shows (.venv) prefix
  8. Run: which python - should show .venv/bin/python

  9. Test Python path:

    python -c "import sys; print(sys.executable)"
    
    Should output: /home/paulb/tracker-restapi/.venv/bin/python

Troubleshooting

Virtual Environment Not Activating

If the virtual environment doesn't activate automatically:

  1. Reload VSCodium:
  2. Command Palette → "Developer: Reload Window"

  3. Manually select interpreter:

  4. Command Palette → "Python: Select Interpreter"
  5. Choose .venv/bin/python

  6. Check virtual environment exists:

    ls -la .venv/bin/python
    

Tests Not Running

If pytest doesn't work:

  1. Verify pytest is installed:
.venv/bin/pytest --version
  1. Check test configuration:
  2. Open .vscode/settings.json
  3. Verify python.testing.pytestPath points to .venv/bin/pytest

  4. Refresh test discovery:

  5. Command Palette → "Python: Discover Tests"

Benefits of This Configuration

  1. Consistency: Everyone on the team uses the same Python environment
  2. Isolation: Project dependencies don't conflict with system Python
  3. Automatic: No manual activation needed when opening terminals
  4. IDE Integration: IntelliSense, linting, and testing use correct Python version
  5. Environment Variables: .env.local automatically loaded for development