1

I am working in the environment when activate the ll_env

me at me in ~/desktop/django/learning_log
$ source ll_env/bin/activate
(ll_env) 
me at me in ~/desktop/django/learning_log
$ 

When change to the parent directory, it still is in the scope of the virtual environment:

(ll_env) 
me at me in ~/desktop/django
$ 

I assumed that ll_env might disappear when jump out of the directory where environment files lives

How Django enable the environment global?

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
  • 2
    `source ll_env/bin/activate` runs a script in the context of your shell. You’re still in the same shell despite changing directories. See also https://stackoverflow.com/questions/990754/how-to-leave-exit-deactivate-a-python-virtualenv – Ry- May 09 '18 at 03:23
  • This doesn't have *anything at all* to do with Django. – Daniel Roseman May 09 '18 at 06:47

3 Answers3

1

It is not the present working directory that determines your environment. To jump out of the virtual environment, you need to deactivate it.

Using the command: deactivate

Abhijith Asokan
  • 1,865
  • 10
  • 14
1

It may seem unintuitive at first, but it's important to understand that the current directory is not related to the active virtualenv. The active virtualenv determines where python should look for installed dependencies, and where it should install new dependencies to. It places that directory on your path, which is all that really matters in the context of working with a given virtualenv.

This means that you can cd anywhere on your system, do a pip install foo, and know that foo will be installed to a known location for the current venv, not to the directory you happen to be sitting in right now.

shacker
  • 14,712
  • 8
  • 89
  • 89
0

virtualenv and virtualenvwrapper give you access to a function called deactivate to stop using the virtual environment.

$ deactivate

It's different with Anaconda environment, You will deactivate it with two-word command:

$ source deactivate
Lemayzeur
  • 8,297
  • 3
  • 23
  • 50