Pages

virtual env Python

Step 1: Existing Virtual Environment

  • files used by different tools.
FileTool
Pipfile / Pipfile.lockPipenv
pyproject.tomlPoetry or modern Python projects
requirements.txtPlain pip / venv
.venv/ folderManual venv (preferred method)
poetry.lockPoetry
environment.ymlConda
.python-versionpyenv

If you spot venv files, then:

pipenv --venv

To find source for current venv:

source example /Users/gregdyche/.local/share/virtualenvs/projects-TRsZtRyM

VS Code: Open the folder.
Press Cmd + Shift + P and select Python: Select Interpreter

  • find the one related to the virtual environment, in this case projects-TRsZtRyM

Step 2: Activate the Virtual

If .venv files, then:

pipenv shell

Step 3: Exit the Virtual Environment

When finished, deactivate the environment:

exit

 1. Double check correct python is being used?

Run this in terminal or a Python shell:

which python

or in Windows:

where python

Then check if the path includes .venv, env, or pipenv — that’s a strong clue you’re in a virtual environment.

2. Which interpreter is being used (especially in VS Code)?

Open the Command Palette:

Cmd/Ctrl + Shift + P → “Python: Select Interpreter

It will show the path and type of environment.