lets say i created a virtualenv called venv (virtualenv venv)
From reading tutorials, i read there are 2 ways to activate virtual env:
-
. venv/bin/activate -
source venv/bin/activate
I think they both accomplish the same thing, but i dont understand whats going on.
Also for number 1, doesnt the “.” just mean the current folder? but it doesnt work if i just type in “venv/bin/activate” without the “.”
any help would be great!
.andsourcedo exactly the same thing, with the only difference being that whilesourceis more readable, it may not be available in all shells.The command runs the contents of the script within the current shell, and this is important in the case of
activate, because one of the things that the script does is exports and modifies environment variables within your current shell.If you were to run it using
./path/to/activate, the script will be run within a subshell and all environment variables that are set will be lost once the script completes and the subshell terminates..has a different meaning depending on the context. It only means “current folder” when used as (or part of) a path.From http://en.wikipedia.org/wiki/Dot_%28Unix%29:
As an aside, I would suggest that you take a look at
virtualenvwrapperwhich provides additional wrapper commands that makevirtualenvmuch easier to use.Using
virtualenvwrapper, switching to an evironment is done simply by calling: