david
david

Reputation: 6795

What does "source" create or activate the virtual env?

I'm brand new to python, using terminal, pip and virtual env. From what I gather, the command 'source' activates the virtual environment and anything you do after that stays in the virtual environment like installing something with pip installs it only in your virtual environment. However, do I need to actually create a folder or choose a location first before I run source? In other words, does source create the virtual environment or only activate one that already exists?

This stuff is really hard to wrap my head around. I think one of the things that is hindering my development is that I'm not familiar with certain directory structures like bin, ect.

Upvotes: 2

Views: 7042

Answers (2)

Dirtycoder
Dirtycoder

Reputation: 125

Look, you need to create the virtual enviroment first, with something like this:

virtualenv venv

Where 'venv' is the destination directory. After that you can run:

source venv/bin/activate

You can take a look at virtualenv help with:

virtualenv --help

Upvotes: 0

Joohwan
Joohwan

Reputation: 2512

Once you create a virtualenv, you will see source created in the directory. You must cd to that particular source and do source activate to start working on that particular virtualenv. Each virtualenv has its own source.

You can also use virtualenv wrapper to make things easier.

Upvotes: 2

Related Questions