Rayyan khan
Rayyan khan

Reputation: 29

When does venv need activation?

When using Pycharm, I make my virtual environment when I m creating a new project and then never have to think about activating it or anything. It works just fine.

When I m using the terminal on my Mac OS, I need to create the virtual environment and then also activate it.

I also have to activate it for VS Code.

How do I know when I need to activate my virtual environment? Thanks.

Upvotes: 1

Views: 101

Answers (1)

victim
victim

Reputation: 65

To activate a virtual environment from the terminal, you need to source a file that the venv module created. This file typically will be in the bin directory of your project (ej. my_project/folder/bin) and will be named activate.

So to activate the environment in your shell you would run the command

source my_project/folder/bin/activate

You should know if you're already IN the virtual environment, when you see the project's name parsed to some part of your shell prompt. If you're already into your virtual environment, you can leave it with the deactivate command.

shell prompt

Upvotes: 1

Related Questions