Activating environment in virtualenvwrapper
Asked Answered
S

5

6

i installed virtualenv and virtualenvwrapper and with this command i created an environment:

mkvirtualenv cv

it works and after creating i was in the new environment. right now i restarted my computer and i want to activate that environment again, but how?

i use this tutorial to install Opencv on my Mac and one of steps is creating new environment. im confused right now:

http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

i uses virtualenv already but im new to virtualenvwrapper and i dont know what i have to do now

Sarmatia answered 12/12, 2015 at 10:58 Comment(0)
A
13

To activate an environment, we use workon command.

workon cv

If you forget the virtualenv name, you can just type:

workon

And you will see a list of available environments.

Atwater answered 12/12, 2015 at 11:2 Comment(3)
when i do this, i get this error: ERROR: Environment '/Users/myname/.virtualenvs/cv' does not contain an activate scriptSarmatia
Manually navigate to that directory and see if the activate script exists. If not, remove the environment using rmvirtualenv and recreate it.Atwater
I am having the same issue. And the activation script is there.Danialah
B
2

virtualenvwrapper works best if you use mkproject instead of mkvirtualenv. This makes a virtualenv and a project directory to put your files that use the virtualenv. After that you can use workon to switch back to your virtualenv and project.

Blubberhead answered 12/12, 2015 at 11:12 Comment(0)
S
2

I ran into the same problem because I misread the docs and accidentally specified the directory where I put my repos as my $WORKON_HOME, so virtualenvwrapper couldn't find my virtualenvs.

$WORKON_HOME should actually be where your virtualenvs live (I like to make mine at ~/.virtualenvs). This is where the command mkvirtualenv creates the virtualenv for your project. Set this environment variables in your .bashrc (or equivalent), make sure your new $WORKON_HOME directory exists, and then make a new virtualenv. That should fix the problem.

Slice answered 14/7, 2016 at 8:26 Comment(0)
S
1

Read the Docs

workon

List or change working virtual environments

$ workon cv
Sippet answered 12/12, 2015 at 11:3 Comment(1)
when i do this, i get this error: ERROR: Environment '/Users/myname/.virtualenvs/cv' does not contain an activate script.Sarmatia
A
1

I too faced the same problem. So first I uninstalled virtualenvwrapper using,

$ sudo pip uninstall virtualenvwrapper

Then I performed the documentation steps again with some changes this time. You can also do the same, it will work.

Install Steps

  1. $ sudo pip install virtualenvwrapper
  2. Now create a directory to store your virtual environment

    $ mkdir ~/.virtualenvs

  3. Now,

    $ export WORKON_HOME=~/.virtualenvs

  4. Now you have to open .bashrc file and add one line to it.

    So, to do this first copy the line written below and then run, $ nano .bashrc And now paste it at the end of the script

    . /usr/local/bin/virtualenvwrapper.sh

    This will add virtualenvwrapper.sh to .bashrc

  5. Now run ,

    source /usr/local/bin/virtualenvwrapper.sh

  6. Finally run to reload .bashrc,

    source ~/.bashrc

  7. Finally you can use mkvirtualenv and workon commands without any problem.

Hope it helps.

Arrack answered 6/12, 2017 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.