1.1 Install Virtualenv

virtualenv is a tool to create isolated Python environments. It can help you to create an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments (and optionally doesn’t access the globally installed libraries either).

Prep. work

Before install it, we need to download the python packages installer, pip (PyPI):

$ sudo apt-get install python-pip

Installation

Then install virtualenv:

$ sudo pip install virtualenv

Usage

Now you can create a directory as your own environment. For example:

$ virtualenv ENV

Where ENV is a directory to place the new virtual environment:

  • ENV/lib/ and ENV/include/: containing supporting library files for a new virtualenv python.
  • ENV/lib/pythonX.X/site-packages/: packages installed in this environment will live here.
  • ENV/bin: containing executables (noticeably a new python). Thus running a script with #! /path/to/ENV/bin/python would run that script under this virtualenv’s python.
  • The crucial packages pip and setuptools are installed, which allow other packages to be easily installed to the environment. This associated pip can be run from ENV/bin/pip.

Now, you can do anything at your virtual environment!

If you want to know more detail, please visit the website User Guide.

results matching ""

    No results matching ""