2
2
Tutorial on Installing Packages
3
3
===============================
4
4
5
- :Page Status: Complete
6
- :Last Reviewed: 2014-09-30
5
+ :Page Status: Incomplete
6
+ :Last Reviewed: 2014-12-24
7
7
8
8
.. contents :: Contents
9
9
:local:
@@ -26,12 +26,8 @@ distribution, or another larger software distribution like Python itself.
26
26
Setup for Installing Packages
27
27
=============================
28
28
29
- This section describes the steps to follow before installing other
30
- Python packages. You will want to install :ref: `pip ` and
31
- :ref: `setuptools `, and in most cases, :ref: `virtualenv ` (unless you're using
32
- `pyvenv `_).
33
-
34
- We recommend the following installation sequence:
29
+ This section describes the steps to follow before installing other Python
30
+ packages.
35
31
36
32
1. Install :ref: `pip ` and :ref: `setuptools `: [3 ]_
37
33
@@ -71,8 +67,8 @@ We recommend the following installation sequence:
71
67
72
68
.. _`Creating and using Virtual Environments` :
73
69
74
- Virtual Environments
75
- ====================
70
+ Creating Virtual Environments
71
+ =============================
76
72
77
73
Python "Virtual Environments" allow Python :term: `packages <Distribution
78
74
Package> ` to be installed in an isolated location for a particular application,
@@ -124,15 +120,22 @@ For more information, see the `virtualenv <http://virtualenv.pypa.io>`_ docs or
124
120
the `pyvenv `_ docs.
125
121
126
122
127
- Installing Python Packages
128
- ==========================
123
+ Use pip for Installing
124
+ ======================
125
+
126
+ :ref: `pip ` is the recommended installer. Below, we'll cover the most common
127
+ usage scenarios. For more detail, see the `pip docs <https://pip.pypa.io >`_,
128
+ which includes a complete `Reference Guide
129
+ <https://pip.pypa.io/en/latest/reference/index.html> `_.
129
130
130
- :ref: `pip ` is the recommended installer, and supports various requirement forms
131
- and options. For details, see the `pip docs
132
- <https://pip.pypa.io> `_.
131
+ There are a few cases where you might want to use `easy_install
132
+ <https://pip.pypa.io/en/latest/reference/index.html> `_ instead of pip. For
133
+ details, see the the :ref: `pip vs easy_install ` breakdown in the :doc: `Advanced
134
+ Topics <additional>` section.
133
135
134
- Examples
135
- --------
136
+
137
+ Installing from PyPI
138
+ ====================
136
139
137
140
Install `SomeProject ` and its dependencies from :term: `PyPI <Python Package
138
141
Index (PyPI)> ` using :ref: `pip:Requirement Specifiers `
@@ -144,21 +147,78 @@ Index (PyPI)>` using :ref:`pip:Requirement Specifiers`
144
147
pip install 'SomeProject>=1.0.4' # minimum version
145
148
146
149
147
- Install a list of requirements specified in a :ref: `Requirements File
148
- <pip:Requirements Files>`.
150
+ Upgrading packages
151
+ ==================
152
+
153
+ Upgrade an already installed `SomeProject ` to the latest from PyPI.
149
154
150
155
::
151
156
152
- pip install -r requirements.txt
157
+ pip install --upgrade SomeProject
153
158
154
159
155
- Upgrade an already installed `SomeProject ` to the latest from PyPI.
160
+ Installing Cached Wheels
161
+ ========================
162
+
163
+ :term: `Wheel ` is a pre-built :term: `distribution <Distribution Package> ` format that
164
+ provides faster installation compared to :term: `Source Distributions (sdist)
165
+ <Source Distribution (or "sdist")> `, especially when a project contains compiled
166
+ extensions.
167
+
168
+ As of v1.5, :ref: `pip ` prefers :term: `wheels <Wheel> ` over :term: `sdists <Source
169
+ Distribution (or "sdist")> ` when searching indexes.
170
+
171
+ Although wheels are `becoming more common <http://pythonwheels.com >`_ on
172
+ :term: `PyPI <Python Package Index (PyPI)> `, if you want all of your dependencies
173
+ converted to wheel, do the following (assuming you're using a :ref: `Requirements
174
+ File <pip:Requirements Files>`):
156
175
157
176
::
158
177
159
- pip install --upgrade SomeProject
178
+ pip wheel --wheel-dir=/local/wheels -r requirements.txt
179
+
180
+ And then to install those requirements just using your local directory of wheels
181
+ (and not from PyPI):
182
+
183
+ ::
184
+
185
+ pip install --no-index --find-links=/local/wheels -r requirements.txt
186
+
187
+
188
+ :term: `Wheel ` is intended to replace :term: `Eggs <Egg> `. For a detailed
189
+ comparison, see :ref: `Wheel vs Egg `.
190
+
191
+
192
+ Installing to the User Site
193
+ ===========================
194
+
195
+ To install :term: `packages <Distribution Package> ` that are isolated to the
196
+ current user, use the ``--user `` flag:
197
+
198
+ ::
199
+
200
+ pip install --user SomeProject
160
201
161
202
203
+ For more information see the `User Installs
204
+ <https://pip.readthedocs.org/en/latest/user_guide.html#user-installs> `_ section
205
+ from the pip docs.
206
+
207
+
208
+ Requirements files
209
+ ==================
210
+
211
+ Install a list of requirements specified in a :ref: `Requirements File
212
+ <pip:Requirements Files>`.
213
+
214
+ ::
215
+
216
+ pip install -r requirements.txt
217
+
218
+
219
+ Installing from VCS
220
+ ===================
221
+
162
222
Install a project from VCS in "editable" mode. For a full breakdown of the
163
223
syntax, see pip's section on :ref: `VCS Support <pip:VCS Support >`.
164
224
@@ -170,13 +230,8 @@ syntax, see pip's section on :ref:`VCS Support <pip:VCS Support>`.
170
230
pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomeProject # from a branch
171
231
172
232
173
- Install a particular source archive file.
174
-
175
- ::
176
-
177
- pip install ./downloads/SomeProject-1.0.4.tar.gz
178
- pip install http://my.package.repo/SomeProject-1.0.4.zip
179
-
233
+ Installing from other Indexes
234
+ =============================
180
235
181
236
Install from an alternate index
182
237
@@ -193,76 +248,70 @@ Package Index (PyPI)>`
193
248
pip install --extra-index-url http://my.package.repo/simple SomeProject
194
249
195
250
196
- Install from a local directory containing archives (and don't check :term: `PyPI
197
- <Python Package Index (PyPI)> `)
198
-
199
- ::
200
251
201
- pip install --no-index --find-links=file:///local/dir/ SomeProject
202
- pip install --no-index --find-links=/local/dir/ SomeProject
203
- pip install --no-index --find-links=relative/dir/ SomeProject
252
+ Installing from a local src tree
253
+ ================================
204
254
205
255
206
- Find pre-release and development versions, in addition to stable versions. By
207
- default, pip only finds stable versions.
256
+ Installing from local src in `Development Mode
257
+ <http://pythonhosted.org/setuptools/setuptools.html#development-mode> `_, i.e. in
258
+ such a way that the project appears to be installed, but yet is still editable
259
+ from the src tree.
208
260
209
261
::
210
262
211
- pip install --pre SomeProject
263
+ pip install -e <path>
212
264
213
- Install a package with `setuptools extras `_.
214
- ::
215
265
216
- $ pip install SomePackage[PDF]
217
- $ pip install SomePackage[PDF]==3.0
218
- $ pip install -e .[PDF]==3.0 # editable project in current directory
266
+ You can also normally from src
219
267
220
- Wheels
221
- ------
268
+ ::
222
269
223
- :term: `Wheel ` is a pre-built :term: `distribution <Distribution Package> ` format that
224
- provides faster installation compared to :term: `Source Distributions (sdist)
225
- <Source Distribution (or "sdist")> `, especially when a project contains compiled
226
- extensions.
270
+ pip install <path>
227
271
228
- As of v1.5, :ref: `pip ` prefers :term: `wheels <Wheel> ` over :term: `sdists <Source
229
- Distribution (or "sdist")> ` when searching indexes.
230
272
231
- Although wheels are ` becoming more common < http://pythonwheels.com >`_ on
232
- :term: ` PyPI <Python Package Index (PyPI)> `, if you want all of your dependencies
233
- converted to wheel, do the following (assuming you're using a :ref: ` Requirements
234
- File <pip:Requirements Files>`):
273
+ Installing from local archives
274
+ ==============================
275
+
276
+ Install a particular source archive file.
235
277
236
278
::
237
279
238
- pip wheel --wheel-dir=/local/wheels -r requirements.txt
280
+ pip install ./downloads/SomeProject-1.0.4.tar.gz
239
281
240
- And then to install those requirements just using your local directory of wheels
241
- (and not from PyPI):
242
282
243
- ::
283
+ Install from a local directory containing archives (and don't check :term: `PyPI
284
+ <Python Package Index (PyPI)> `)
244
285
245
- pip install --no-index --find-links=/local/wheels -r requirements.txt
286
+ ::
246
287
288
+ pip install --no-index --find-links=file:///local/dir/ SomeProject
289
+ pip install --no-index --find-links=/local/dir/ SomeProject
290
+ pip install --no-index --find-links=relative/dir/ SomeProject
247
291
248
- :term: `Wheel ` is intended to replace :term: `Eggs <Egg> `. For a detailed
249
- comparison, see :ref: `Wheel vs Egg `.
250
292
251
293
252
- User Installs
253
- -------------
294
+ Installing Prereleases
295
+ ======================
254
296
255
- To install :term: ` packages <Distribution Package> ` that are isolated to the
256
- current user, use the `` --user `` flag:
297
+ Find pre-release and development versions, in addition to stable versions. By
298
+ default, pip only finds stable versions.
257
299
258
300
::
259
301
260
- pip install --user SomeProject
302
+ pip install --pre SomeProject
261
303
262
304
263
- For more information see the `User Installs
264
- <https://pip.readthedocs.org/en/latest/user_guide.html#user-installs> `_ section
265
- from the pip docs.
305
+ Installing Setuptools "Extras"
306
+ ==============================
307
+
308
+ Install `setuptools extras `_.
309
+
310
+ ::
311
+
312
+ $ pip install SomePackage[PDF]
313
+ $ pip install SomePackage[PDF]==3.0
314
+ $ pip install -e .[PDF]==3.0 # editable project in current directory
266
315
267
316
268
317
@@ -288,5 +337,7 @@ from the pip docs.
288
337
pre-installed, thereby making it an equal alternative to
289
338
:ref: `virtualenv `.
290
339
340
+ .. [5 ]
341
+
291
342
.. _pyvenv : http://docs.python.org/3.4/library/venv.html
292
343
.. _setuptools extras : http://packages.python.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
0 commit comments