Skip to content

Commit 100a4cb

Browse files
author
Can Ibanoglu
committed
Created a new section for virtualenv and pip
1 parent d17acbf commit 100a4cb

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

docs/starting/install/osx.rst

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -118,50 +118,6 @@ copy your code out of it, and then delete the main directory for the environment
118118
An useful set of extensions to virtualenv is available in virtualenvwrapper,
119119
`RTFD <http://virtualenvwrapper.readthedocs.org/en/latest/>`_ to find out more.
120120

121-
122-
A note about Pip and Virtualenv
123-
-------------------------------
124-
125-
By now it should be clear that using virtual environments is a great way to keep
126-
your development environment clean and keeping different projects' requirements
127-
separate.
128-
129-
When you start working on many different projects, it can be hard to remember to
130-
activate the related virtual environment when you come back to a specific project.
131-
As a result of this, it is very easy to install packages globally while thinking
132-
that you are actually installing the package for the virtual environment of the
133-
project. Over time this can result in a messy global package list.
134-
135-
In order to make sure that you install packages to your active virtual environment
136-
when you use ``pip install``, consider adding the following two lines to your
137-
``~/.bashrc`` file:
138-
139-
.. code-block:: console
140-
export PIP_REQUIRE_VIRTUALENV=true
141-
142-
After saving this change and sourcing the ``~/.bashrc`` file with ``source ~/.bashrc``,
143-
pip will no longer let you install packages if you are not in a virtual environment.
144-
If you try to use ``pip install`` outside of a virtual environment pip will
145-
gently remind you that an activated virtual environment is needed to install
146-
packages.
147-
148-
.. code-block:: console
149-
$ pip install requests
150-
Could not find an activated virtualenv (required).
151-
152-
You will of course need to install some packages globally and this can be accomplished
153-
by adding the following to your ``~/.bashrc`` file:
154-
155-
.. code-block:: console
156-
gpip() {
157-
PIP_REQUIRE_VIRTUALENV="" pip "$@"
158-
}
159-
160-
After saving the changes and sourcing your ``~/.bashrc`` file you can now install
161-
packages globally by running ``gpip install``. You can change the name of the
162-
function to anything you like, just keep in mind that you will have to use that
163-
name when trying install packages globally with pip.
164-
165121
--------------------------------
166122

167123
This page is a remixed version of `another guide <http://www.stuartellis.eu/articles/python-development-windows/>`_,

docs/starting/pip-virtualenv.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.. _pip-virtualenv:
2+
3+
Further Configuration of Pip and Virtualenv
4+
-------------------------------------------
5+
6+
By now it should be clear that using virtual envirtonments is a great way to keep
7+
your development environment clean and keeping different projects' requirements
8+
separate.
9+
10+
When you start working on many different projects, it can be hard to remember to
11+
activate the related virtual environment when you come back to a specific project.
12+
As a result of this, it is very easy to install packages globally while thinking
13+
that you are actually installing the package for the virtual environment of the
14+
project. Over time this can result in a messy global package list.
15+
16+
In order to make sure that you install packages to your active virtual environment
17+
when you use ``pip install``, consider adding the following two lines to your
18+
``~/.bashrc`` file:
19+
20+
.. code-block:: console
21+
export PIP_REQUIRE_VIRTUALENV=true
22+
23+
After saving this change and sourcing the ``~/.bashrc`` file with ``source ~/.bashrc``,
24+
pip will no longer let you install packages if you are not in a virtual environment.
25+
If you try to use ``pip install`` outside of a virtual environment pip will gently
26+
remind you that an activated virtual environment is needed to install packages.
27+
28+
.. code-block:: console
29+
$ pip install requests
30+
Could not find an activated virtualenv (required).
31+
32+
You will of course need to install some packages globally (usually ones that you
33+
use across different projects consistenly) and this can be accomplished by adding
34+
the following to your ``~/.bashrc`` file:
35+
36+
.. code-block:: console
37+
gpip() {
38+
PIP_REQUIRE_VIRTUALENV="" pip "$@"
39+
}
40+
41+
After saving the changes and sourcing your ``~/.bashrc`` file you can now install
42+
packages globally by running ``gpip install``. You can change the name of the
43+
function to anything you like, just keep in mind that you will have to use that
44+
name when trying to install packages globally with pip.
45+
46+
-----------------------------------------------------------

0 commit comments

Comments
 (0)