A simple VS Code extension for managing a Python virtual environment in the current workspace folder.
- automatic Python interpreter detection,
- automatic creation of a
.venvenvironment in the workspace directory, - ability to delete and reinitialize
.venv, - detection of imports in
.pyscripts and installation of missing libraries viapip, - selection of a Python script from the side panel,
- running the selected script using the interpreter from
.venv, - script output in the Output channel:
Python Venv Toolkit.
- VS Code 1.108.1 or newer,
- Python 3.x available in
PATHor in a standard system location, - npm.
npm installnpm run compileThen, in VS Code, start extension debugging by pressing F5.
- Open a workspace folder in VS Code.
- Open the
Python Venvpanel from the Activity Bar. - The extension will detect Python and create
.venvin the opened folder. - Place or select any
.pyscript in the workspace directory. - In the panel, select a script from the list and click
Run Script.
Scripts are run with the working directory set to the opened VS Code folder. If the script imports external libraries, use the Install dependencies from imports button.
Optionally, you can add a script name and description in a comment or docstring:
"""SCRIPT_NAME: Daily reportSCRIPT_DESCRIPTION: Generates a report from data in the current folder."""importpandasaspdprint("Start")Older headers RULE_NAME and RULE_DESCRIPTION are also supported.
src/
├── extension.ts
├── MainViewProvider.ts
├── pythonDetector.ts
├── scriptRunner.ts
├── scriptValidator.ts
└── venvManager.ts
npm install
npm run package
npx @vscode/vsce package --no-dependenciesThe resulting file will have a name like python-venv-toolkit-0.1.0.vsix.
