krazzle
krazzle

Reputation: 73

Do you need to activate your virtual environment each time you need to use it?

I have managed to create a virtual environment in windows and installed the packages I want to have using pip in the environment (tensorflow). My question is, how do I tell a script I write to use the virtual environment instead of the main form of python on my system?

I know how to activate it using path/to/venv/Scripts/activate in the command terminal, but would I have to do this each time before running the script in the terminal? That would be really inconvenient for me since I like to try out the code I write to see if it works (usually doesn't haha) in an IDE (I switch between IDLE and Spyder from Anaconda).

I am a total beginner so if there's a simple solution I porbably just don't know about it, appreciate any help :)

Cheers!

Upvotes: 7

Views: 3127

Answers (1)

user12867493
user12867493

Reputation:

According to the docs you simply need to activate your virtual environment using the following on Windows:

.\env\Scripts\activate

This has to be done every time you use it, to save time just keep a Terminal window open.

To leave the virtual environment, deactivate it:

.../env/bin/python.exe

Upvotes: 2

Related Questions