9

I have some noob level virtual environment questions. I've been using virtual environments a little but still have a few questions.

I have created and activated an env which is my main working environment as follows:

virtualenv env
source /path/to/environment/env/bin/activate

Having activated this, I can now see I am in the environment as I have (env) visible on command line.

My first question is, do I need to run the activate command each time I open a terminal session? And therefore each time I turn my laptop on, etc.?

Further, I want to create another environment that runs on an earlier version of python for testing purposes. I was intending to do it as follows:

virtualenv --python=python2.7 env-py2
source /path/to/new/environment/env-py2/bin/activate

Can these virtualenvs be switched easily? So can I activate env-py2 and then easily jump back to activate env again? Or is there an inbetween step required?

Apologies for the very basic questions but I was struggling to find high level information.

2
  • 1
    You might want to look at github.com/pyenv/pyenv Commented Oct 7, 2020 at 14:18
  • 2
    just run deactivate and source the other Commented Oct 7, 2020 at 14:20

1 Answer 1

11

Yes you need to run activate command i.e. source each time you open a terminal session.

Switching between two virtual environment is easy. You can run deactivate command and source the other virtual environment.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.