Reader small image

You're reading from  Python Data Visualization Cookbook

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781782163367
Edition1st Edition
Languages
Right arrow
Author (1)
Igor Milovanovic
Igor Milovanovic
author image
Igor Milovanovic

Igor Milovanović is an experienced developer, with strong background in Linux system knowledge and software engineering education. He is skilled in building scalable data-driven distributed software rich systems. An evangelist for high-quality systems design, he has a strong interest in software architecture and development methodologies. Igor is always committed to advocating methodologies that promote high-quality software, such as test-driven development, one-step builds, and continuous integration. He also possesses solid knowledge of product development. With field experience and official training, he is capable of transferring knowledge and communication flow from business to developers and vice versa. Igor is most grateful to his girlfriend for letting him spend hours on work instead with her and being an avid listener to his endless book monologues. He thanks his brother for being the strongest supporter. He is also thankful to his parents for letting him develop in various ways to become a person he is today.
Read more about Igor Milovanovic

Right arrow

Installing virtualenv and virtualenvwrapper


If you are working on many projects simultaneously, or even just switching between them frequently, you'll find that having everything installed system-wide is not the best option and can bring problems in future on different systems (production) where you want to run your software. This is not a good time to find out that you are missing a certain package or have versioning conflicts between packages that are already installed on production system; hence, virtualenv.

virtualenv is an open source project started by Ian Bicking that enables a developer to isolate working environments per project, for easier maintenance of different package versions.

For example, you inherited legacy Django website based on Django 1.1 and Python 2.3, but at the same time you are working on a new project that must be written in Python 2.6. This is my usual case—having more than one required Python version (and related packages) depending on the project I am working on.

virtualenv enables me to easily switch to different environments and have the same package easily reproduced if I need to switch to another machine or to deploy software to a production server (or to a client's workstation).

Getting ready

To install virtualenv, you must have workable installation of Python and pip. Pip is a tool for installing and managing Python packages, and it is a replacement for easy install. We will use pip through most of this book for package management. Pip is easily installed, as root executes the following line in your terminal:

# easy_install pip

virtualenv by itself is really useful, but with the help of virtualenvwrapper, all this becomes easy to do and also easy to organize many virtual environments. See all the features at http://virtualenvwrapper.readthedocs.org/en/latest/#features.

How to do it...

By performing the following steps you can install the virtualenv and virtualenvwrapper tools:

  1. Install virtualenv and virtualenvwrapper:

    $ sudo pip virtualenv
    $ sudo pip virtualenvwrapper
    # Create folder to hold all our virtual environments and export the path to it.
    $ export VIRTENV=~/.virtualenvs
    $ mkdir -p $VIRTENV
    # We source (ie. execute) shell script to activate the wrappers
    $ source /usr/local/bin/virtualenvwrapper.sh
    # And create our first virtual environment
    $ mkvirtualenv virt1
    
  2. You can now install our favorite package inside virt1:

    (virt1)user1:~$ pip install matplotlib
    
  3. You will probably want to add the following line to your ~/.bashrc file:

    source /usr/loca/bin/virtualenvwrapper.sh

Few useful and most frequently used commands are as follows:

  • mkvirtualenv ENV: This creates virtual environment with name ENV and activates it

  • workon ENV: This activates the previously created ENV

  • deactivate: This gets us out of the current virtual environment

Previous PageNext Page
You have been reading a chapter from
Python Data Visualization Cookbook
Published in: Nov 2013Publisher: PacktISBN-13: 9781782163367
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Igor Milovanovic

Igor Milovanović is an experienced developer, with strong background in Linux system knowledge and software engineering education. He is skilled in building scalable data-driven distributed software rich systems. An evangelist for high-quality systems design, he has a strong interest in software architecture and development methodologies. Igor is always committed to advocating methodologies that promote high-quality software, such as test-driven development, one-step builds, and continuous integration. He also possesses solid knowledge of product development. With field experience and official training, he is capable of transferring knowledge and communication flow from business to developers and vice versa. Igor is most grateful to his girlfriend for letting him spend hours on work instead with her and being an avid listener to his endless book monologues. He thanks his brother for being the strongest supporter. He is also thankful to his parents for letting him develop in various ways to become a person he is today.
Read more about Igor Milovanovic