Issue
I am planning to install a virtual environment for Python in order to keep my Python packages separate. One of the motivations for this is also to have two versions of Python on my machine (Ubuntu 14.04) co-existing. I have the following wonders:
- In what order should Python, PIP and virtualenv be installed? Does it matter at all?
- Once done, how can I keep two python versions separate under virtualenv?
- Assume I am working on separate projects, is it recommended to keep each of the project in a separate folder created by virtualenv or not?
I would like to know experts opinion in order to do things in the right manner and wisely.
Solution
Using virtualenv is common amongst Python programmers. These links will be more useful than my answers:
- http://docs.python-guide.org/en/latest/dev/virtualenvs/
http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
Yes, it does matter. Pip uses Python, but since Ubuntu comes pre-installed with a version of Python (In your case both 2 and 3 are installed), you shouldn't have to worry about this. But the order would be Python -> PIP -> virtualenv.
Once you
cd
in a new, empty project folder, you can create the virtualenv with the Python version of your choice withvirtualenv -p /path/to/python/version venv
. You can find the path withwhich python2
orwhich python3
.If I understand your question correctly - yes. The whole point of virtualenv is to keep each project in a separate folder with its own virtualenv set up. Even with a small project, you will just become more familiar with the concept of virtualenv (and maybe even containers like Docker).
Answered By - HoppyKamper Answer Checked By - Mary Flores (WPSolving Volunteer)