Steven You
Steven You

Reputation: 459

Explain virtualenv activate command

In Flask documentation, for activating the virtualenv environment, the command is:

$ . venv/bin/activate

Can anyone explain how it works, what's the first dot and why the shell script file in the second param in the shell command.

Upvotes: 3

Views: 2475

Answers (2)

paweloque
paweloque

Reputation: 18864

The . command corresponds to the 'source' command. It causes the env settings set within the executed script (in this case activate) to be kept after script execution. It means that the env settings set in the script will still be available after it returns.

The activate itself will change the executed python, i.e. after calling activate, the 'python' command will refer to the local python installation set up with virtualenv. This is necessary to have several 'python' environments with different libs installed.

After activation you will see which python is actually used by a prompt prefix.

Upvotes: 2

thebjorn
thebjorn

Reputation: 27311

It is the source command/dot operator, see e.g. http://ss64.com/bash/period.html

Upvotes: 8

Related Questions