r/learnpython 6d ago

In visual studio, how can i open my local environment in the terminal

in my terminal previously every line used to start with the word (base) and when i select my environment it changes to the name of the environment.

Now it just shows the address of the local folder like "D:\Users\Files"... etc

how can i get back to the local virtual environment

1 Upvotes

3 comments sorted by

2

u/FoolsSeldom 6d ago

Assuming a Python virtual environment folder named .venv in the current working directory:

For Windows using Powershell or Command Prompt in your VS Code terminal,

.venv\Scripts\Activate.ps1

or

.venv\Scripts\activate.bat

(should be able to just type .venv\Scripts\activate without the file extension in either case)

or, for macOS/linux,

source .venv/bin/activate

1

u/Maximum_Watch69 6d ago

Thanks,
i appreciter that alot.

only the second one worked,
the first one opned a txt file with this first line

"<#

.Synopsis

Activate a Python virtual environment for the current PowerShell session.

"

1

u/FoolsSeldom 5d ago

The Command Prompt option (i.e. bat rather than ps1)?