Skip to content

Commit 0a1925f

Browse files
committed
Tidy up virtual_environment.rst
Some small fixes.
1 parent 6b9608d commit 0a1925f

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

virtual_environment.rst

+32-28
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
Virtual Environment
22
-------------------
33

4-
Have you ever heard of ``virtualenv``? The chances are that if you are a
5-
beginner then you might not have heard about it but if you are a
6-
seasoned programmer than it's a vital part of your toolset. So what
7-
``virtualenv`` really is? ``Virtualenv`` is a tool which allows us to
4+
Have you ever heard of ``virtualenv``? If you are a beginner,
5+
then you might not have heard about it but if you are a
6+
seasoned programmer then it may well be a vital part of your toolset.
7+
8+
So what is ``virtualenv``? ``Virtualenv`` is a tool which allows us to
89
make isolated python environments. Imagine you have an application that
9-
needs version 2 of a LibraryBar, but another application requires
10+
needs version 2 of a library, but another application requires
1011
version 3. How can you use and develop both these applications?
1112

1213
If you install everything into ``/usr/lib/python2.7/site-packages`` (or
1314
whatever your platform's standard location is), it's easy to end up in a
14-
situation where you unintentionally upgrade a package that shouldn't be
15-
upgraded. In another case just imagine that you have an application
16-
which is fully developed and you do not want to make any change to the
17-
libraries it is using but at the same time you start developing another
18-
application which requires the updated versions of those libraries. What
19-
will you do? It is where ``virtualenv`` comes into play. It creates
20-
isolated environments for your python application and allows you to
21-
install Python libraries in that isolated environment instead of
22-
installing them globally.
23-
24-
In order to install it just type this command in the shell:
15+
situation where you unintentionally upgrade a package.
16+
17+
In another case, imagine that you have an application which is fully
18+
developed and you do not want to make any change to the libraries it is
19+
using but at the same time you start developing another application
20+
which requires the updated versions of those libraries.
21+
22+
What will you do? Use ``virtualenv``! It creates isolated environments
23+
for your python application and allows you to install Python libraries
24+
in that isolated environment instead of installing them globally.
25+
26+
To install it, just type this command in the shell:
2527

2628
.. code:: python
2729
2830
$ pip install virtualenv
2931
30-
Now i am going to list some of it's commands. The most important ones
31-
are:
32+
The most important commands are:
3233

3334
- ``$ virtualenv myproject``
3435
- ``$ source bin/activate``
3536

3637
This first one makes an isolated virtualenv environment in the
3738
``myproject`` folder and the second command activates that isolated
38-
environment. While running the first command you have to make a
39-
decision.
39+
environment.
40+
41+
While creating the virtualenv you have to make a decision. Do you
42+
want this virtualenv to use packages from your system ``site-packages``
43+
or install them in the virtualenv’s site-packages? By default,
44+
virtualenv will not give access to the global ``site-packages``.
4045

41-
Do you want this virtualenv to use packages from your system
42-
``site-packages`` or install them in the virtualenv’s site-packages? By
43-
default, virtualenv will not give access to the global ``site-packages``.
4446
If you want your ``virtualenv`` to have access to your systems
45-
``site-packages`` use the ``--system-site-packages`` switch when creating
47+
``site-packages``, use the ``--system-site-packages`` switch when creating
4648
your virtualenv like this:
4749

4850
.. code:: python
@@ -55,6 +57,9 @@ You can turn off the ``env`` by typing:
5557
5658
$ deactivate
5759
60+
Running `python` after deactivating will use your system installation
61+
of Python again.
62+
5863
**Bonus**
5964

6065
You can use ``smartcd`` which is a library for bash and zsh and allows
@@ -63,7 +68,6 @@ helpful to activate and deactivate a ``virtualenv`` when you change
6368
directories. I have used it quite a lot and love it. You can read more
6469
about it on `GitHub <https://github.com/cxreg/smartcd>`__
6570

66-
This was just a short intro to virtualenv. There's a lot more to it. For
67-
further study i recommend `this
68-
link. <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`__
69-
It will remove all of your confusions about virtualenv.
71+
This was just a short intro to virtualenv. There's a lot more to it; `this
72+
link <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`__ has more
73+
information.

0 commit comments

Comments
 (0)