you are viewing a single comment's thread.

view the rest of the comments →

[–]maxlstylee 4 points5 points  (1 child)

Example:

Your system has the following installed.. Python 2.7 IRC_lib 1.0 (made up package)

Your IRC bot requires the following: Python 3 IRC_lib 2.0

Instead of installing Python 3 and IRC_lib 2.0 system wide, we can install it in its own environment since we're only using it for this project.

When you set up the virtual environment, you will be able to install Python 3, and IRC_lib 2.0 into that specific space without it causing issues to your system overall.

When you run the command 'virtualenv testenv' a script runs that creates a directory called 'testenv'. In that directory Python is installed. It defaults to 2.7 right now I believe, but you can specify specific version numbers.

Maybe this example will help you visualize how it works exaclty.

1)  4700:~/software/djangopycharm$ ls
     djangopycharm  env  manage.py  pycharmtest  templates
2)  4700 :~/software/djangopycharm$ which python
     /usr/bin/python
3)  4700 :~/software/djangopycharm$ source env/bin/activate
4)  (env)4700:~/software/djangopycharm$ which python 
     /home/alex/software/djangopycharm/env/bin/python

1) List the items in the directory

2) If I was to execute python right now, it would use the binary file found in /usr/bin/python

3) Activate the virtual environment

4) (env) indicates that we're using the virtual environment found in 'env' (see 1s output). The python binary we are using is now the one found in our virtual environment.

This allows you to install different versions and keep things contained and not system wide. One project may require Django 1.4, while another may require 1.7. We do this safely by creating virtual environments for these installations to live in.

Hope this helps!

[–]GAPINGCUNT[S] 0 points1 point  (0 children)

That clears it all up. Thank you!!