Skip to content

Commit c939324

Browse files
authored
Merge pull request realpython#687 from adamn/master
Removed references to Setuptools/easy_install in favor of pip.
2 parents 2d21986 + 0d3c9a1 commit c939324

File tree

4 files changed

+161
-31
lines changed

4 files changed

+161
-31
lines changed

docs/dev/virtualenvs.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ virtualenv
1515
----------
1616

1717
`virtualenv <http://pypi.python.org/pypi/virtualenv>`_ is a tool to create
18-
isolated Python environments. virtualenv creates a folder which contains all the
19-
necessary executables to use the packages that a Python project would need.
18+
isolated Python environments. virtualenv creates a folder which contains all the
19+
necessary executables to use the packages that a Python project would need.
2020

2121
Install virtualenv via pip:
2222

@@ -43,23 +43,28 @@ in the current directory instead.
4343
This creates a copy of Python in whichever directory you ran the command in,
4444
placing it in a folder named :file:`venv`.
4545

46-
You can also use a Python interpreter of your choice.
46+
You can also use the Python interpreter of your choice (like
47+
:file:`/usr/bin/python2.7`).
4748

4849
.. code-block:: console
4950
5051
$ virtualenv -p /usr/bin/python2.7 venv
5152
52-
This will use the Python interpreter in :file:`/usr/bin/python2.7`
53+
or change the interpreter globally with an env variable in ``~/.bashrc``:
54+
55+
.. code-block:: console
56+
57+
$ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
5358
5459
2. To begin using the virtual environment, it needs to be activated:
5560

5661
.. code-block:: console
5762
5863
$ source venv/bin/activate
5964
60-
The name of the current virtual environment will now appear on the left of
61-
the prompt (e.g. ``(venv)Your-Computer:your_project UserName$)`` to let you know
62-
that it's active. From now on, any package that you install using pip will be
65+
The name of the current virtual environment will now appear on the left of
66+
the prompt (e.g. ``(venv)Your-Computer:your_project UserName$)`` to let you know
67+
that it's active. From now on, any package that you install using pip will be
6368
placed in the ``venv`` folder, isolated from the global Python installation.
6469

6570
Install packages as usual, for example:
@@ -78,7 +83,7 @@ Install packages as usual, for example:
7883
This puts you back to the system's default Python interpreter with all its
7984
installed libraries.
8085

81-
To delete a virtual environment, just delete its folder. (In this case,
86+
To delete a virtual environment, just delete its folder. (In this case,
8287
it would be ``rm -rf venv``.)
8388

8489
After a while, though, you might end up with a lot of virtual environments
@@ -102,8 +107,8 @@ the current state of the environment packages. To do this, run
102107
103108
This will create a :file:`requirements.txt` file, which contains a simple
104109
list of all the packages in the current environment, and their respective
105-
versions. You can see the list of installed packages without the requirements
106-
format using "pip list". Later it will be easier for a different developer
110+
versions. You can see the list of installed packages without the requirements
111+
format using "pip list". Later it will be easier for a different developer
107112
(or you, if you need to re-create the environment) to install the same packages
108113
using the same versions:
109114

@@ -143,7 +148,7 @@ To install (make sure **virtualenv** is already installed):
143148
.. code-block:: console
144149
145150
$ pip install virtualenvwrapper-win
146-
151+
147152
In Windows, the default path for WORKON_HOME is %USERPROFILE%\Envs
148153

149154
Basic Usage

docs/starting/install/osx.rst

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
Installing Python on Mac OS X
44
=============================
55

6+
.. note::
7+
Check out our :ref:`guide for installing Python 3 on OS X<install3-osx>`.
8+
69
The latest version of Mac OS X, El Capitan, **comes with Python 2.7 out of the box**.
710

8-
You do not need to install or configure anything else to use Python. Having
9-
said that, I would strongly recommend that you install the tools and libraries
10-
described in the next section before you start building Python applications
11-
for real-world use. In particular, you should always install Setuptools, as it
12-
makes it much easier for you to use other third-party Python libraries.
11+
You do not need to install or configure anything else to use Python. Having said
12+
that, I would strongly recommend that you install the tools and libraries
13+
described in the next section before you start building Python applications for
14+
real-world use. In particular, you should always install Setuptools, as it makes
15+
it much easier for you to install and manage other third-party Python libraries.
1316

1417
The version of Python that ships with OS X is great for learning but it's not
1518
good for development. The version shipped with OS X may be out of date from the
@@ -30,9 +33,14 @@ minimal but unofficial
3033
package.
3134

3235
.. note::
33-
If you already have Xcode installed or plan to use Homebrew, do not install
34-
OSX-GCC-Installer. In combination, the software can cause issues that are
35-
difficult to diagnose.
36+
If you already have XCode installed, do not install OSX-GCC-Installer.
37+
In combination, the software can cause issues that are difficult to
38+
diagnose.
39+
40+
.. note::
41+
If you perform a fresh install of XCode, you will also need to add the
42+
commandline tools by running ``xcode-select --install`` on the terminal.
43+
3644

3745
While OS X comes with a large number of UNIX utilities, those familiar with
3846
Linux systems will notice one key component missing: a decent package manager.
@@ -70,7 +78,7 @@ or Python 3:
7078
This will take a minute or two.
7179

7280

73-
Setuptools & Pip
81+
Setuptools and Pip
7482
----------------
7583

7684
Homebrew installs Setuptools and ``pip`` for you.
@@ -81,23 +89,23 @@ software over a network (usually the Internet) with a single command
8189
capability to your own Python software with very little work.
8290

8391
``pip`` is a tool for easily installing and managing Python packages,
84-
that is recommended over ``easy_install``. It is superior to ``easy_install`` in `several ways <https://python-packaging-user-guide.readthedocs.io/pip_easy_install/#pip-vs-easy-install>`_,
92+
that is recommended over ``easy_install``. It is superior to ``easy_install``
93+
in `several ways <https://python-packaging-user-guide.readthedocs.io/pip_easy_install/#pip-vs-easy-install>`_,
8594
and is actively maintained.
8695

8796

8897
Virtual Environments
8998
--------------------
9099

91-
A Virtual Environment is a tool to keep the dependencies required by different projects
92-
in separate places, by creating virtual Python environments for them. It solves the
93-
"Project X depends on version 1.x but, Project Y needs 4.x" dilemma, and keeps
100+
A Virtual Environment (commonly referred to as a 'virtualenv') is a tool to keep the dependencies required by different projects
101+
in separate places, by creating virtual Python environments for them. It solves the
102+
"Project X depends on version 1.x but, Project Y needs 4.x" dilemma, and keeps
94103
your global site-packages directory clean and manageable.
95104

96105
For example, you can work on a project which requires Django 1.10 while also
97106
maintaining a project which requires Django 1.8.
98107

99-
To start using this and see more information: :ref:`Virtual Environments <virtualenvironments-ref>` docs.
100-
108+
To start using this and see more information: :ref:`Virtual Environments <virtualenvironments-ref>` docs.
101109

102110
--------------------------------
103111

docs/starting/install3/osx.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
.. _install3-osx:
2+
3+
Installing Python 3 on Mac OS X
4+
================================
5+
6+
The latest version of Mac OS X, El Capitan, **comes with Python 2.7 out of the box**.
7+
8+
You do not need to install or configure anything else to use Python 2. These
9+
instructions document the installation of Python 3.
10+
11+
The version of Python that ships with OS X is great for learning but it's not
12+
good for development. The version shipped with OS X may be out of date from the
13+
`official current Python release <https://www.python.org/downloads/mac-osx/>`_,
14+
which is considered the stable production version.
15+
16+
Doing it Right
17+
--------------
18+
19+
Let's install a real version of Python.
20+
21+
Before installing Python, you'll need to install GCC. GCC can be obtained
22+
by downloading `XCode <http://developer.apple.com/xcode/>`_, the smaller
23+
`Command Line Tools <https://developer.apple.com/downloads/>`_ (must have an
24+
Apple account) or the even smaller `OSX-GCC-Installer <https://github.com/kennethreitz/osx-gcc-installer#readme>`_
25+
package.
26+
27+
.. note::
28+
If you already have XCode installed, do not install OSX-GCC-Installer.
29+
In combination, the software can cause issues that are difficult to
30+
diagnose.
31+
32+
.. note::
33+
If you perform a fresh install of XCode, you will also need to add the
34+
commandline tools by running ``xcode-select --install`` on the terminal.
35+
36+
While OS X comes with a large number of UNIX utilities, those familiar with
37+
Linux systems will notice one key component missing: a package manager.
38+
`Homebrew <http://brew.sh>`_ fills this void.
39+
40+
To `install Homebrew <http://brew.sh/#install>`_, open :file:`Terminal` or
41+
your favorite OSX terminal emulator and run
42+
43+
.. code-block:: console
44+
45+
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
46+
47+
The script will explain what changes it will make and prompt you before the
48+
installation begins.
49+
Once you've installed Homebrew, insert the Homebrew directory at the top
50+
of your :envvar:`PATH` environment variable. You can do this by adding the following
51+
line at the bottom of your :file:`~/.profile` file
52+
53+
.. code-block:: console
54+
55+
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
56+
57+
Now, we can install Python 3:
58+
59+
.. code-block:: console
60+
61+
$ brew install python3
62+
63+
This will take a minute or two.
64+
65+
66+
Pip
67+
----------------
68+
69+
Homebrew installs ``pip3`` for you.
70+
71+
``pip3`` is the alias for the Python 3 version of ``pip`` on systems with both
72+
the Homebrew'd Python 2 and 3 installed.
73+
74+
Working with Python3
75+
--------------------
76+
77+
At this point, you have the system Python 2.7 available, potentially the
78+
:ref:`Homebrew version of Python 2 <install-osx>` installed, and the Homebrew
79+
version of Python 3 as well.
80+
81+
.. code-block:: console
82+
83+
$ python
84+
85+
will launch the Python 2 interpreter.
86+
87+
.. code-block:: console
88+
89+
$ python3
90+
91+
will launch the Python 3 interpreter
92+
93+
``pip3`` and ``pip`` will both be available. If the Homebrew version of Python
94+
2 is not installed, they will be the same. If the Homebrew version of Python 2
95+
is installed then ``pip`` will point to Python 2 and ``pip3`` will point to
96+
Python 3.
97+
98+
99+
Virtual Environments
100+
--------------------
101+
102+
A Virtual Environment (commonly referred to as a 'virtualenv') is a tool to keep
103+
the dependencies required by different projects in separate places, by creating
104+
virtual Python environments for them. It solves the "Project X depends on
105+
version 1.x but, Project Y needs 4.x" dilemma, and keeps your global
106+
site-packages directory clean and manageable.
107+
108+
For example, you can work on a project which requires Django 1.10 while also
109+
maintaining a project which requires Django 1.8.
110+
111+
To start using this and see more information: :ref:`Virtual Environments <virtualenvironments-ref>` docs.
112+
113+
--------------------------------
114+
115+
This page is a remixed version of `another guide <http://www.stuartellis.eu/articles/python-development-windows/>`_,
116+
which is available under the same license.

docs/starting/installation.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ other third-party Python libraries.
1313
Installation Guides
1414
-------------------
1515

16-
These guides go over the proper installation of :ref:`Python 2.7 <which-python>`
17-
for development purposes, as well as setuptools, pip, and virtualenv setup.
16+
These guides go over the proper installation of :ref:`Python <which-python>`
17+
for development purposes, as well as setuptools, pip and virtualenv.
1818

19-
- :ref:`Mac OS X <install-osx>`.
20-
- :ref:`Microsoft Windows <install-windows>`.
21-
- :ref:`Linux <install-linux>`.
19+
- :ref:`Python 3 on MacOS <install3-osx>`.
20+
- :ref:`Python 2 on MacOS <install-osx>`.
21+
- :ref:`Python 2 on Microsoft Windows <install-windows>`.
22+
- :ref:`Python 2 on Ubuntu Linux <install-linux>`.

0 commit comments

Comments
 (0)