r/Python • • Apr 30 '18

xkcd: Python Environment

Post image
2.4k Upvotes

388 comments sorted by

View all comments

Show parent comments

1

u/7heWafer May 01 '18

Let's add that to the graph somewhere!

0

u/2freevl2frank May 01 '18

No. The thing is this isnt added to the graph. Its outside the graph.

From /u/meandertothehorizon above

Virtualenv copies and/or symlinks or hardlinks the files from system python necessary to create a second, segregated install in an arbitrary directory on your computer. You run/source a file from the command line in that directory (activate.sh/activate.bat) that modifies the environment to reference this copied version so anything you do - install packages, run python itself, etc will use this copy instead of system. This prevents clobbering the system setup if you install or upgrade arbitrary system packages. When you are done, or want to create another virtualenv, or run system python, you run ‘deactivate’ which will undo the environment modifications - so running python will again reference the system python. Any packages you installed will be ‘gone’ because they reside in the copied environment.