mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Removed virtualenv and linked to central location
This commit is contained in:
@@ -45,41 +45,18 @@ To install pip, simply open a command prompt and run
|
||||
$ easy_install pip
|
||||
|
||||
|
||||
Virtualenv
|
||||
Virtual Environments
|
||||
----------
|
||||
|
||||
After Setuptools & Pip, the next development tool that you should install is
|
||||
`virtualenv <http://pypi.python.org/pypi/virtualenv/>`_. Use pip
|
||||
A Virtual Environment is a tool to keep the dependencies required by different projects
|
||||
in separate places, by creating virtual Python environments for them. It solves the
|
||||
"Project X depends on version 1.x but, Project Y needs 4.x" dilemma, and keeps
|
||||
your global site-packages directory clean and manageable.
|
||||
|
||||
.. code-block:: console
|
||||
For example, you can work on a project which requires Django 1.3 while also
|
||||
maintaining a project which requires Django 1.0.
|
||||
|
||||
$ pip install virtualenv
|
||||
|
||||
The virtualenv kit provides the ability to create virtual Python environments
|
||||
that do not interfere with either each other, or the main Python installation.
|
||||
If you install virtualenv before you begin coding then you can get into the
|
||||
habit of using it to create completely clean Python environments for each
|
||||
project. This is particularly important for Web development, where each
|
||||
framework and application will have many dependencies.
|
||||
|
||||
To set up a new Python environment, change the working directory to where ever
|
||||
you want to store the environment, and run the virtualenv utility in your
|
||||
project's directory
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ virtualenv venv
|
||||
|
||||
To use an environment, run ``source venv/bin/activate``. Your command prompt
|
||||
will change to show the active environment. Once you have finished working in
|
||||
the current virtual environment, run ``deactivate`` to restore your settings
|
||||
to normal.
|
||||
|
||||
Each new environment automatically includes a copy of ``pip``, so that you can
|
||||
setup the third-party libraries and tools that you want to use in that
|
||||
environment. Put your own code within a subdirectory of the environment,
|
||||
however you wish. When you no longer need a particular environment, simply
|
||||
copy your code out of it, and then delete the main directory for the environment.
|
||||
To start using and see more information: `Virtual Environments <http://github.com/kennethreitz/python-guide/blob/master/docs/dev/virtualenvs.rst>`_ docs.
|
||||
|
||||
|
||||
--------------------------------
|
||||
|
||||
Reference in New Issue
Block a user