1============ 2Easy Install 3============ 4 5.. warning:: 6 Easy Install is deprecated. Do not use it. Instead use pip. If 7 you think you need Easy Install, please reach out to the PyPA 8 team (a ticket to pip or setuptools is fine), describing your 9 use-case. 10 11Easy Install is a python module (``easy_install``) bundled with ``setuptools`` 12that lets you automatically download, build, install, and manage Python 13packages. 14 15Please share your experiences with us! If you encounter difficulty installing 16a package, please contact us via the `distutils mailing list 17<http://mail.python.org/pipermail/distutils-sig/>`_. (Note: please DO NOT send 18private email directly to the author of setuptools; it will be discarded. The 19mailing list is a searchable archive of previously-asked and answered 20questions; you should begin your research there before reporting something as a 21bug -- and then do so via list discussion first.) 22 23(Also, if you'd like to learn about how you can use ``setuptools`` to make your 24own packages work better with EasyInstall, or provide EasyInstall-like features 25without requiring your users to use EasyInstall directly, you'll probably want 26to check out the full documentation as well.) 27 28Using "Easy Install" 29==================== 30 31 32.. _installation instructions: 33 34Installing "Easy Install" 35------------------------- 36 37Please see the :pypi:`setuptools` on the package index 38for download links and basic installation instructions for each of the 39supported platforms. 40 41You will need at least Python 3.5 or 2.7. An ``easy_install`` script will be 42installed in the normal location for Python scripts on your platform. 43 44Note that the instructions on the setuptools PyPI page assume that you are 45are installing to Python's primary ``site-packages`` directory. If this is 46not the case, you should consult the section below on `Custom Installation 47Locations`_ before installing. (And, on Windows, you should not use the 48``.exe`` installer when installing to an alternate location.) 49 50Note that ``easy_install`` normally works by downloading files from the 51internet. If you are behind an NTLM-based firewall that prevents Python 52programs from accessing the net directly, you may wish to first install and use 53the `APS proxy server <http://ntlmaps.sf.net/>`_, which lets you get past such 54firewalls in the same way that your web browser(s) do. 55 56(Alternately, if you do not wish easy_install to actually download anything, you 57can restrict it from doing so with the ``--allow-hosts`` option; see the 58sections on `restricting downloads with --allow-hosts`_ and `command-line 59options`_ for more details.) 60 61 62Troubleshooting 63~~~~~~~~~~~~~~~ 64 65If EasyInstall/setuptools appears to install correctly, and you can run the 66``easy_install`` command but it fails with an ``ImportError``, the most likely 67cause is that you installed to a location other than ``site-packages``, 68without taking any of the steps described in the `Custom Installation 69Locations`_ section below. Please see that section and follow the steps to 70make sure that your custom location will work correctly. Then re-install. 71 72Similarly, if you can run ``easy_install``, and it appears to be installing 73packages, but then you can't import them, the most likely issue is that you 74installed EasyInstall correctly but are using it to install packages to a 75non-standard location that hasn't been properly prepared. Again, see the 76section on `Custom Installation Locations`_ for more details. 77 78 79Windows Notes 80~~~~~~~~~~~~~ 81 82Installing setuptools will provide an ``easy_install`` command according to 83the techniques described in `Executables and Launchers`_. If the 84``easy_install`` command is not available after installation, that section 85provides details on how to configure Windows to make the commands available. 86 87 88Downloading and Installing a Package 89------------------------------------ 90 91For basic use of ``easy_install``, you need only supply the filename or URL of 92a source distribution or .egg file (`Python Egg`__). 93 94__ http://peak.telecommunity.com/DevCenter/PythonEggs 95 96**Example 1**. Install a package by name, searching PyPI for the latest 97version, and automatically downloading, building, and installing it:: 98 99 easy_install SQLObject 100 101**Example 2**. Install or upgrade a package by name and version by finding 102links on a given "download page":: 103 104 easy_install -f http://pythonpaste.org/package_index.html SQLObject 105 106**Example 3**. Download a source distribution from a specified URL, 107automatically building and installing it:: 108 109 easy_install http://example.com/path/to/MyPackage-1.2.3.tgz 110 111**Example 4**. Install an already-downloaded .egg file:: 112 113 easy_install /my_downloads/OtherPackage-3.2.1-py2.3.egg 114 115**Example 5**. Upgrade an already-installed package to the latest version 116listed on PyPI:: 117 118 easy_install --upgrade PyProtocols 119 120**Example 6**. Install a source distribution that's already downloaded and 121extracted in the current directory (New in 0.5a9):: 122 123 easy_install . 124 125**Example 7**. (New in 0.6a1) Find a source distribution or Subversion 126checkout URL for a package, and extract it or check it out to 127``~/projects/sqlobject`` (the name will always be in all-lowercase), where it 128can be examined or edited. (The package will not be installed, but it can 129easily be installed with ``easy_install ~/projects/sqlobject``. See `Editing 130and Viewing Source Packages`_ below for more info.):: 131 132 easy_install --editable --build-directory ~/projects SQLObject 133 134**Example 7**. (New in 0.6.11) Install a distribution within your home dir:: 135 136 easy_install --user SQLAlchemy 137 138Easy Install accepts URLs, filenames, PyPI package names (i.e., ``distutils`` 139"distribution" names), and package+version specifiers. In each case, it will 140attempt to locate the latest available version that meets your criteria. 141 142When downloading or processing downloaded files, Easy Install recognizes 143distutils source distribution files with extensions of .tgz, .tar, .tar.gz, 144.tar.bz2, or .zip. And of course it handles already-built .egg 145distributions as well as ``.win32.exe`` installers built using distutils. 146 147By default, packages are installed to the running Python installation's 148``site-packages`` directory, unless you provide the ``-d`` or ``--install-dir`` 149option to specify an alternative directory, or specify an alternate location 150using distutils configuration files. (See `Configuration Files`_, below.) 151 152By default, any scripts included with the package are installed to the running 153Python installation's standard script installation location. However, if you 154specify an installation directory via the command line or a config file, then 155the default directory for installing scripts will be the same as the package 156installation directory, to ensure that the script will have access to the 157installed package. You can override this using the ``-s`` or ``--script-dir`` 158option. 159 160Installed packages are added to an ``easy-install.pth`` file in the install 161directory, so that Python will always use the most-recently-installed version 162of the package. If you would like to be able to select which version to use at 163runtime, you should use the ``-m`` or ``--multi-version`` option. 164 165 166Upgrading a Package 167------------------- 168 169You don't need to do anything special to upgrade a package: just install the 170new version, either by requesting a specific version, e.g.:: 171 172 easy_install "SomePackage==2.0" 173 174a version greater than the one you have now:: 175 176 easy_install "SomePackage>2.0" 177 178using the upgrade flag, to find the latest available version on PyPI:: 179 180 easy_install --upgrade SomePackage 181 182or by using a download page, direct download URL, or package filename:: 183 184 easy_install -f http://example.com/downloads ExamplePackage 185 186 easy_install http://example.com/downloads/ExamplePackage-2.0-py2.4.egg 187 188 easy_install my_downloads/ExamplePackage-2.0.tgz 189 190If you're using ``-m`` or ``--multi-version`` , using the ``require()`` 191function at runtime automatically selects the newest installed version of a 192package that meets your version criteria. So, installing a newer version is 193the only step needed to upgrade such packages. 194 195If you're installing to a directory on PYTHONPATH, or a configured "site" 196directory (and not using ``-m``), installing a package automatically replaces 197any previous version in the ``easy-install.pth`` file, so that Python will 198import the most-recently installed version by default. So, again, installing 199the newer version is the only upgrade step needed. 200 201If you haven't suppressed script installation (using ``--exclude-scripts`` or 202``-x``), then the upgraded version's scripts will be installed, and they will 203be automatically patched to ``require()`` the corresponding version of the 204package, so that you can use them even if they are installed in multi-version 205mode. 206 207``easy_install`` never actually deletes packages (unless you're installing a 208package with the same name and version number as an existing package), so if 209you want to get rid of older versions of a package, please see `Uninstalling 210Packages`_, below. 211 212 213Changing the Active Version 214--------------------------- 215 216If you've upgraded a package, but need to revert to a previously-installed 217version, you can do so like this:: 218 219 easy_install PackageName==1.2.3 220 221Where ``1.2.3`` is replaced by the exact version number you wish to switch to. 222If a package matching the requested name and version is not already installed 223in a directory on ``sys.path``, it will be located via PyPI and installed. 224 225If you'd like to switch to the latest installed version of ``PackageName``, you 226can do so like this:: 227 228 easy_install PackageName 229 230This will activate the latest installed version. (Note: if you have set any 231``find_links`` via distutils configuration files, those download pages will be 232checked for the latest available version of the package, and it will be 233downloaded and installed if it is newer than your current version.) 234 235Note that changing the active version of a package will install the newly 236active version's scripts, unless the ``--exclude-scripts`` or ``-x`` option is 237specified. 238 239 240Uninstalling Packages 241--------------------- 242 243If you have replaced a package with another version, then you can just delete 244the package(s) you don't need by deleting the PackageName-versioninfo.egg file 245or directory (found in the installation directory). 246 247If you want to delete the currently installed version of a package (or all 248versions of a package), you should first run:: 249 250 easy_install -m PackageName 251 252This will ensure that Python doesn't continue to search for a package you're 253planning to remove. After you've done this, you can safely delete the .egg 254files or directories, along with any scripts you wish to remove. 255 256 257Managing Scripts 258---------------- 259 260Whenever you install, upgrade, or change versions of a package, EasyInstall 261automatically installs the scripts for the selected package version, unless 262you tell it not to with ``-x`` or ``--exclude-scripts``. If any scripts in 263the script directory have the same name, they are overwritten. 264 265Thus, you do not normally need to manually delete scripts for older versions of 266a package, unless the newer version of the package does not include a script 267of the same name. However, if you are completely uninstalling a package, you 268may wish to manually delete its scripts. 269 270EasyInstall's default behavior means that you can normally only run scripts 271from one version of a package at a time. If you want to keep multiple versions 272of a script available, however, you can simply use the ``--multi-version`` or 273``-m`` option, and rename the scripts that EasyInstall creates. This works 274because EasyInstall installs scripts as short code stubs that ``require()`` the 275matching version of the package the script came from, so renaming the script 276has no effect on what it executes. 277 278For example, suppose you want to use two versions of the ``rst2html`` tool 279provided by the `docutils <http://docutils.sf.net/>`_ package. You might 280first install one version:: 281 282 easy_install -m docutils==0.3.9 283 284then rename the ``rst2html.py`` to ``r2h_039``, and install another version:: 285 286 easy_install -m docutils==0.3.10 287 288This will create another ``rst2html.py`` script, this one using docutils 289version 0.3.10 instead of 0.3.9. You now have two scripts, each using a 290different version of the package. (Notice that we used ``-m`` for both 291installations, so that Python won't lock us out of using anything but the most 292recently-installed version of the package.) 293 294 295Executables and Launchers 296------------------------- 297 298On Unix systems, scripts are installed with as natural files with a "#!" 299header and no extension and they launch under the Python version indicated in 300the header. 301 302On Windows, there is no mechanism to "execute" files without extensions, so 303EasyInstall provides two techniques to mirror the Unix behavior. The behavior 304is indicated by the SETUPTOOLS_LAUNCHER environment variable, which may be 305"executable" (default) or "natural". 306 307Regardless of the technique used, the script(s) will be installed to a Scripts 308directory (by default in the Python installation directory). It is recommended 309for EasyInstall that you ensure this directory is in the PATH environment 310variable. The easiest way to ensure the Scripts directory is in the PATH is 311to run ``Tools\Scripts\win_add2path.py`` from the Python directory. 312 313Note that instead of changing your ``PATH`` to include the Python scripts 314directory, you can also retarget the installation location for scripts so they 315go on a directory that's already on the ``PATH``. For more information see 316`Command-Line Options`_ and `Configuration Files`_. During installation, 317pass command line options (such as ``--script-dir``) to control where 318scripts will be installed. 319 320 321Windows Executable Launcher 322~~~~~~~~~~~~~~~~~~~~~~~~~~~ 323 324If the "executable" launcher is used, EasyInstall will create a '.exe' 325launcher of the same name beside each installed script (including 326``easy_install`` itself). These small .exe files launch the script of the 327same name using the Python version indicated in the '#!' header. 328 329This behavior is currently default. To force 330the use of executable launchers, set ``SETUPTOOLS_LAUNCHER`` to "executable". 331 332Natural Script Launcher 333~~~~~~~~~~~~~~~~~~~~~~~ 334 335EasyInstall also supports deferring to an external launcher such as 336`pylauncher <https://bitbucket.org/pypa/pylauncher>`_ for launching scripts. 337Enable this experimental functionality by setting the 338``SETUPTOOLS_LAUNCHER`` environment variable to "natural". EasyInstall will 339then install scripts as simple 340scripts with a .pya (or .pyw) extension appended. If these extensions are 341associated with the pylauncher and listed in the PATHEXT environment variable, 342these scripts can then be invoked simply and directly just like any other 343executable. This behavior may become default in a future version. 344 345EasyInstall uses the .pya extension instead of simply 346the typical '.py' extension. This distinct extension is necessary to prevent 347Python 348from treating the scripts as importable modules (where name conflicts exist). 349Current releases of pylauncher do not yet associate with .pya files by 350default, but future versions should do so. 351 352 353Tips & Techniques 354----------------- 355 356Multiple Python Versions 357~~~~~~~~~~~~~~~~~~~~~~~~ 358 359EasyInstall installs itself under two names: 360``easy_install`` and ``easy_install-N.N``, where ``N.N`` is the Python version 361used to install it. Thus, if you install EasyInstall for both Python 3.2 and 3622.7, you can use the ``easy_install-3.2`` or ``easy_install-2.7`` scripts to 363install packages for the respective Python version. 364 365Setuptools also supplies easy_install as a runnable module which may be 366invoked using ``python -m easy_install`` for any Python with Setuptools 367installed. 368 369Restricting Downloads with ``--allow-hosts`` 370~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 372You can use the ``--allow-hosts`` (``-H``) option to restrict what domains 373EasyInstall will look for links and downloads on. ``--allow-hosts=None`` 374prevents downloading altogether. You can also use wildcards, for example 375to restrict downloading to hosts in your own intranet. See the section below 376on `Command-Line Options`_ for more details on the ``--allow-hosts`` option. 377 378By default, there are no host restrictions in effect, but you can change this 379default by editing the appropriate `configuration files`_ and adding: 380 381.. code-block:: ini 382 383 [easy_install] 384 allow_hosts = *.myintranet.example.com,*.python.org 385 386The above example would then allow downloads only from hosts in the 387``python.org`` and ``myintranet.example.com`` domains, unless overridden on the 388command line. 389 390 391Installing on Un-networked Machines 392~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 394Just copy the eggs or source packages you need to a directory on the target 395machine, then use the ``-f`` or ``--find-links`` option to specify that 396directory's location. For example:: 397 398 easy_install -H None -f somedir SomePackage 399 400will attempt to install SomePackage using only eggs and source packages found 401in ``somedir`` and disallowing all remote access. You should of course make 402sure you have all of SomePackage's dependencies available in somedir. 403 404If you have another machine of the same operating system and library versions 405(or if the packages aren't platform-specific), you can create the directory of 406eggs using a command like this:: 407 408 easy_install -zmaxd somedir SomePackage 409 410This will tell EasyInstall to put zipped eggs or source packages for 411SomePackage and all its dependencies into ``somedir``, without creating any 412scripts or .pth files. You can then copy the contents of ``somedir`` to the 413target machine. (``-z`` means zipped eggs, ``-m`` means multi-version, which 414prevents .pth files from being used, ``-a`` means to copy all the eggs needed, 415even if they're installed elsewhere on the machine, and ``-d`` indicates the 416directory to place the eggs in.) 417 418You can also build the eggs from local development packages that were installed 419with the ``setup.py develop`` command, by including the ``-l`` option, e.g.:: 420 421 easy_install -zmaxld somedir SomePackage 422 423This will use locally-available source distributions to build the eggs. 424 425 426Packaging Others' Projects As Eggs 427~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 429Need to distribute a package that isn't published in egg form? You can use 430EasyInstall to build eggs for a project. You'll want to use the ``--zip-ok``, 431``--exclude-scripts``, and possibly ``--no-deps`` options (``-z``, ``-x`` and 432``-N``, respectively). Use ``-d`` or ``--install-dir`` to specify the location 433where you'd like the eggs placed. By placing them in a directory that is 434published to the web, you can then make the eggs available for download, either 435in an intranet or to the internet at large. 436 437If someone distributes a package in the form of a single ``.py`` file, you can 438wrap it in an egg by tacking an ``#egg=name-version`` suffix on the file's URL. 439So, something like this:: 440 441 easy_install -f "http://some.example.com/downloads/foo.py#egg=foo-1.0" foo 442 443will install the package as an egg, and this:: 444 445 easy_install -zmaxd. \ 446 -f "http://some.example.com/downloads/foo.py#egg=foo-1.0" foo 447 448will create a ``.egg`` file in the current directory. 449 450 451Creating your own Package Index 452~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 453 454In addition to local directories and the Python Package Index, EasyInstall can 455find download links on most any web page whose URL is given to the ``-f`` 456(``--find-links``) option. In the simplest case, you can simply have a web 457page with links to eggs or Python source packages, even an automatically 458generated directory listing (such as the Apache web server provides). 459 460If you are setting up an intranet site for package downloads, you may want to 461configure the target machines to use your download site by default, adding 462something like this to their `configuration files`_: 463 464.. code-block:: ini 465 466 [easy_install] 467 find_links = http://mypackages.example.com/somedir/ 468 http://turbogears.org/download/ 469 http://peak.telecommunity.com/dist/ 470 471As you can see, you can list multiple URLs separated by whitespace, continuing 472on multiple lines if necessary (as long as the subsequent lines are indented. 473 474If you are more ambitious, you can also create an entirely custom package index 475or PyPI mirror. See the ``--index-url`` option under `Command-Line Options`_, 476below, and also the section on `Package Index "API"`_. 477 478 479Password-Protected Sites 480------------------------ 481 482If a site you want to download from is password-protected using HTTP "Basic" 483authentication, you can specify your credentials in the URL, like so:: 484 485 http://some_userid:[email protected]/some_path/ 486 487You can do this with both index page URLs and direct download URLs. As long 488as any HTML pages read by easy_install use *relative* links to point to the 489downloads, the same user ID and password will be used to do the downloading. 490 491Using .pypirc Credentials 492------------------------- 493 494In additional to supplying credentials in the URL, ``easy_install`` will also 495honor credentials if present in the .pypirc file. Teams maintaining a private 496repository of packages may already have defined access credentials for 497uploading packages according to the distutils documentation. ``easy_install`` 498will attempt to honor those if present. Refer to the distutils documentation 499for Python 2.5 or later for details on the syntax. 500 501Controlling Build Options 502~~~~~~~~~~~~~~~~~~~~~~~~~ 503 504EasyInstall respects standard distutils `Configuration Files`_, so you can use 505them to configure build options for packages that it installs from source. For 506example, if you are on Windows using the MinGW compiler, you can configure the 507default compiler by putting something like this: 508 509.. code-block:: ini 510 511 [build] 512 compiler = mingw32 513 514into the appropriate distutils configuration file. In fact, since this is just 515normal distutils configuration, it will affect any builds using that config 516file, not just ones done by EasyInstall. For example, if you add those lines 517to ``distutils.cfg`` in the ``distutils`` package directory, it will be the 518default compiler for *all* packages you build. See `Configuration Files`_ 519below for a list of the standard configuration file locations, and links to 520more documentation on using distutils configuration files. 521 522 523Editing and Viewing Source Packages 524~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 525 526Sometimes a package's source distribution contains additional documentation, 527examples, configuration files, etc., that are not part of its actual code. If 528you want to be able to examine these files, you can use the ``--editable`` 529option to EasyInstall, and EasyInstall will look for a source distribution 530or Subversion URL for the package, then download and extract it or check it out 531as a subdirectory of the ``--build-directory`` you specify. If you then wish 532to install the package after editing or configuring it, you can do so by 533rerunning EasyInstall with that directory as the target. 534 535Note that using ``--editable`` stops EasyInstall from actually building or 536installing the package; it just finds, obtains, and possibly unpacks it for 537you. This allows you to make changes to the package if necessary, and to 538either install it in development mode using ``setup.py develop`` (if the 539package uses setuptools, that is), or by running ``easy_install projectdir`` 540(where ``projectdir`` is the subdirectory EasyInstall created for the 541downloaded package. 542 543In order to use ``--editable`` (``-e`` for short), you *must* also supply a 544``--build-directory`` (``-b`` for short). The project will be placed in a 545subdirectory of the build directory. The subdirectory will have the same 546name as the project itself, but in all-lowercase. If a file or directory of 547that name already exists, EasyInstall will print an error message and exit. 548 549Also, when using ``--editable``, you cannot use URLs or filenames as arguments. 550You *must* specify project names (and optional version requirements) so that 551EasyInstall knows what directory name(s) to create. If you need to force 552EasyInstall to use a particular URL or filename, you should specify it as a 553``--find-links`` item (``-f`` for short), and then also specify 554the project name, e.g.:: 555 556 easy_install -eb ~/projects \ 557 -fhttp://prdownloads.sourceforge.net/ctypes/ctypes-0.9.6.tar.gz?download \ 558 ctypes==0.9.6 559 560 561Dealing with Installation Conflicts 562~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 563 564(NOTE: As of 0.6a11, this section is obsolete; it is retained here only so that 565people using older versions of EasyInstall can consult it. As of version 5660.6a11, installation conflicts are handled automatically without deleting the 567old or system-installed packages, and without ignoring the issue. Instead, 568eggs are automatically shifted to the front of ``sys.path`` using special 569code added to the ``easy-install.pth`` file. So, if you are using version 5700.6a11 or better of setuptools, you do not need to worry about conflicts, 571and the following issues do not apply to you.) 572 573EasyInstall installs distributions in a "managed" way, such that each 574distribution can be independently activated or deactivated on ``sys.path``. 575However, packages that were not installed by EasyInstall are "unmanaged", 576in that they usually live all in one directory and cannot be independently 577activated or deactivated. 578 579As a result, if you are using EasyInstall to upgrade an existing package, or 580to install a package with the same name as an existing package, EasyInstall 581will warn you of the conflict. (This is an improvement over ``setup.py 582install``, because the ``distutils`` just install new packages on top of old 583ones, possibly combining two unrelated packages or leaving behind modules that 584have been deleted in the newer version of the package.) 585 586EasyInstall will stop the installation if it detects a conflict 587between an existing, "unmanaged" package, and a module or package in any of 588the distributions you're installing. It will display a list of all of the 589existing files and directories that would need to be deleted for the new 590package to be able to function correctly. To proceed, you must manually 591delete these conflicting files and directories and re-run EasyInstall. 592 593Of course, once you've replaced all of your existing "unmanaged" packages with 594versions managed by EasyInstall, you won't have any more conflicts to worry 595about! 596 597 598Compressed Installation 599~~~~~~~~~~~~~~~~~~~~~~~ 600 601EasyInstall tries to install packages in zipped form, if it can. Zipping 602packages can improve Python's overall import performance if you're not using 603the ``--multi-version`` option, because Python processes zipfile entries on 604``sys.path`` much faster than it does directories. 605 606As of version 0.5a9, EasyInstall analyzes packages to determine whether they 607can be safely installed as a zipfile, and then acts on its analysis. (Previous 608versions would not install a package as a zipfile unless you used the 609``--zip-ok`` option.) 610 611The current analysis approach is fairly conservative; it currently looks for: 612 613 * Any use of the ``__file__`` or ``__path__`` variables (which should be 614 replaced with ``pkg_resources`` API calls) 615 616 * Possible use of ``inspect`` functions that expect to manipulate source files 617 (e.g. ``inspect.getsource()``) 618 619 * Top-level modules that might be scripts used with ``python -m`` (Python 2.4) 620 621If any of the above are found in the package being installed, EasyInstall will 622assume that the package cannot be safely run from a zipfile, and unzip it to 623a directory instead. You can override this analysis with the ``-zip-ok`` flag, 624which will tell EasyInstall to install the package as a zipfile anyway. Or, 625you can use the ``--always-unzip`` flag, in which case EasyInstall will always 626unzip, even if its analysis says the package is safe to run as a zipfile. 627 628Normally, however, it is simplest to let EasyInstall handle the determination 629of whether to zip or unzip, and only specify overrides when needed to work 630around a problem. If you find you need to override EasyInstall's guesses, you 631may want to contact the package author and the EasyInstall maintainers, so that 632they can make appropriate changes in future versions. 633 634(Note: If a package uses ``setuptools`` in its setup script, the package author 635has the option to declare the package safe or unsafe for zipped usage via the 636``zip_safe`` argument to ``setup()``. If the package author makes such a 637declaration, EasyInstall believes the package's author and does not perform its 638own analysis. However, your command-line option, if any, will still override 639the package author's choice.) 640 641 642Reference Manual 643================ 644 645Configuration Files 646------------------- 647 648(New in 0.4a2) 649 650You may specify default options for EasyInstall using the standard 651distutils configuration files, under the command heading ``easy_install``. 652EasyInstall will look first for a ``setup.cfg`` file in the current directory, 653then a ``~/.pydistutils.cfg`` or ``$HOME\\pydistutils.cfg`` (on Unix-like OSes 654and Windows, respectively), and finally a ``distutils.cfg`` file in the 655``distutils`` package directory. Here's a simple example: 656 657.. code-block:: ini 658 659 [easy_install] 660 661 # set the default location to install packages 662 install_dir = /home/me/lib/python 663 664 # Notice that indentation can be used to continue an option 665 # value; this is especially useful for the "--find-links" 666 # option, which tells easy_install to use download links on 667 # these pages before consulting PyPI: 668 # 669 find_links = http://sqlobject.org/ 670 http://peak.telecommunity.com/dist/ 671 672In addition to accepting configuration for its own options under 673``[easy_install]``, EasyInstall also respects defaults specified for other 674distutils commands. For example, if you don't set an ``install_dir`` for 675``[easy_install]``, but *have* set an ``install_lib`` for the ``[install]`` 676command, this will become EasyInstall's default installation directory. Thus, 677if you are already using distutils configuration files to set default install 678locations, build options, etc., EasyInstall will respect your existing settings 679until and unless you override them explicitly in an ``[easy_install]`` section. 680 681For more information, see also the current Python documentation on the `use and 682location of distutils configuration files <https://docs.python.org/install/index.html#inst-config-files>`_. 683 684Notice that ``easy_install`` will use the ``setup.cfg`` from the current 685working directory only if it was triggered from ``setup.py`` through the 686``install_requires`` option. The standalone command will not use that file. 687 688Command-Line Options 689-------------------- 690 691``--zip-ok, -z`` 692 Install all packages as zip files, even if they are marked as unsafe for 693 running as a zipfile. This can be useful when EasyInstall's analysis 694 of a non-setuptools package is too conservative, but keep in mind that 695 the package may not work correctly. (Changed in 0.5a9; previously this 696 option was required in order for zipped installation to happen at all.) 697 698``--always-unzip, -Z`` 699 Don't install any packages as zip files, even if the packages are marked 700 as safe for running as a zipfile. This can be useful if a package does 701 something unsafe, but not in a way that EasyInstall can easily detect. 702 EasyInstall's default analysis is currently very conservative, however, so 703 you should only use this option if you've had problems with a particular 704 package, and *after* reporting the problem to the package's maintainer and 705 to the EasyInstall maintainers. 706 707 (Note: the ``-z/-Z`` options only affect the installation of newly-built 708 or downloaded packages that are not already installed in the target 709 directory; if you want to convert an existing installed version from 710 zipped to unzipped or vice versa, you'll need to delete the existing 711 version first, and re-run EasyInstall.) 712 713``--multi-version, -m`` 714 "Multi-version" mode. Specifying this option prevents ``easy_install`` from 715 adding an ``easy-install.pth`` entry for the package being installed, and 716 if an entry for any version the package already exists, it will be removed 717 upon successful installation. In multi-version mode, no specific version of 718 the package is available for importing, unless you use 719 ``pkg_resources.require()`` to put it on ``sys.path``. This can be as 720 simple as:: 721 722 from pkg_resources import require 723 require("SomePackage", "OtherPackage", "MyPackage") 724 725 which will put the latest installed version of the specified packages on 726 ``sys.path`` for you. (For more advanced uses, like selecting specific 727 versions and enabling optional dependencies, see the ``pkg_resources`` API 728 doc.) 729 730 Changed in 0.6a10: this option is no longer silently enabled when 731 installing to a non-PYTHONPATH, non-"site" directory. You must always 732 explicitly use this option if you want it to be active. 733 734``--upgrade, -U`` (New in 0.5a4) 735 By default, EasyInstall only searches online if a project/version 736 requirement can't be met by distributions already installed 737 on sys.path or the installation directory. However, if you supply the 738 ``--upgrade`` or ``-U`` flag, EasyInstall will always check the package 739 index and ``--find-links`` URLs before selecting a version to install. In 740 this way, you can force EasyInstall to use the latest available version of 741 any package it installs (subject to any version requirements that might 742 exclude such later versions). 743 744``--install-dir=DIR, -d DIR`` 745 Set the installation directory. It is up to you to ensure that this 746 directory is on ``sys.path`` at runtime, and to use 747 ``pkg_resources.require()`` to enable the installed package(s) that you 748 need. 749 750 (New in 0.4a2) If this option is not directly specified on the command line 751 or in a distutils configuration file, the distutils default installation 752 location is used. Normally, this would be the ``site-packages`` directory, 753 but if you are using distutils configuration files, setting things like 754 ``prefix`` or ``install_lib``, then those settings are taken into 755 account when computing the default installation directory, as is the 756 ``--prefix`` option. 757 758``--script-dir=DIR, -s DIR`` 759 Set the script installation directory. If you don't supply this option 760 (via the command line or a configuration file), but you *have* supplied 761 an ``--install-dir`` (via command line or config file), then this option 762 defaults to the same directory, so that the scripts will be able to find 763 their associated package installation. Otherwise, this setting defaults 764 to the location where the distutils would normally install scripts, taking 765 any distutils configuration file settings into account. 766 767``--exclude-scripts, -x`` 768 Don't install scripts. This is useful if you need to install multiple 769 versions of a package, but do not want to reset the version that will be 770 run by scripts that are already installed. 771 772``--user`` (New in 0.6.11) 773 Use the user-site-packages as specified in :pep:`370` 774 instead of the global site-packages. 775 776``--always-copy, -a`` (New in 0.5a4) 777 Copy all needed distributions to the installation directory, even if they 778 are already present in a directory on sys.path. In older versions of 779 EasyInstall, this was the default behavior, but now you must explicitly 780 request it. By default, EasyInstall will no longer copy such distributions 781 from other sys.path directories to the installation directory, unless you 782 explicitly gave the distribution's filename on the command line. 783 784 Note that as of 0.6a10, using this option excludes "system" and 785 "development" eggs from consideration because they can't be reliably 786 copied. This may cause EasyInstall to choose an older version of a package 787 than what you expected, or it may cause downloading and installation of a 788 fresh copy of something that's already installed. You will see warning 789 messages for any eggs that EasyInstall skips, before it falls back to an 790 older version or attempts to download a fresh copy. 791 792``--find-links=URLS_OR_FILENAMES, -f URLS_OR_FILENAMES`` 793 Scan the specified "download pages" or directories for direct links to eggs 794 or other distributions. Any existing file or directory names or direct 795 download URLs are immediately added to EasyInstall's search cache, and any 796 indirect URLs (ones that don't point to eggs or other recognized archive 797 formats) are added to a list of additional places to search for download 798 links. As soon as EasyInstall has to go online to find a package (either 799 because it doesn't exist locally, or because ``--upgrade`` or ``-U`` was 800 used), the specified URLs will be downloaded and scanned for additional 801 direct links. 802 803 Eggs and archives found by way of ``--find-links`` are only downloaded if 804 they are needed to meet a requirement specified on the command line; links 805 to unneeded packages are ignored. 806 807 If all requested packages can be found using links on the specified 808 download pages, the Python Package Index will not be consulted unless you 809 also specified the ``--upgrade`` or ``-U`` option. 810 811 (Note: if you want to refer to a local HTML file containing links, you must 812 use a ``file:`` URL, as filenames that do not refer to a directory, egg, or 813 archive are ignored.) 814 815 You may specify multiple URLs or file/directory names with this option, 816 separated by whitespace. Note that on the command line, you will probably 817 have to surround the URL list with quotes, so that it is recognized as a 818 single option value. You can also specify URLs in a configuration file; 819 see `Configuration Files`_, above. 820 821 Changed in 0.6a10: previously all URLs and directories passed to this 822 option were scanned as early as possible, but from 0.6a10 on, only 823 directories and direct archive links are scanned immediately; URLs are not 824 retrieved unless a package search was already going to go online due to a 825 package not being available locally, or due to the use of the ``--update`` 826 or ``-U`` option. 827 828``--no-find-links`` Blocks the addition of any link. 829 This parameter is useful if you want to avoid adding links defined in a 830 project easy_install is installing (whether it's a requested project or a 831 dependency). When used, ``--find-links`` is ignored. 832 833 Added in Distribute 0.6.11 and Setuptools 0.7. 834 835``--index-url=URL, -i URL`` (New in 0.4a1; default changed in 0.6c7) 836 Specifies the base URL of the Python Package Index. The default is 837 https://pypi.org/simple/ if not specified. When a package is requested 838 that is not locally available or linked from a ``--find-links`` download 839 page, the package index will be searched for download pages for the needed 840 package, and those download pages will be searched for links to download 841 an egg or source distribution. 842 843``--editable, -e`` (New in 0.6a1) 844 Only find and download source distributions for the specified projects, 845 unpacking them to subdirectories of the specified ``--build-directory``. 846 EasyInstall will not actually build or install the requested projects or 847 their dependencies; it will just find and extract them for you. See 848 `Editing and Viewing Source Packages`_ above for more details. 849 850``--build-directory=DIR, -b DIR`` (UPDATED in 0.6a1) 851 Set the directory used to build source packages. If a package is built 852 from a source distribution or checkout, it will be extracted to a 853 subdirectory of the specified directory. The subdirectory will have the 854 same name as the extracted distribution's project, but in all-lowercase. 855 If a file or directory of that name already exists in the given directory, 856 a warning will be printed to the console, and the build will take place in 857 a temporary directory instead. 858 859 This option is most useful in combination with the ``--editable`` option, 860 which forces EasyInstall to *only* find and extract (but not build and 861 install) source distributions. See `Editing and Viewing Source Packages`_, 862 above, for more information. 863 864``--verbose, -v, --quiet, -q`` (New in 0.4a4) 865 Control the level of detail of EasyInstall's progress messages. The 866 default detail level is "info", which prints information only about 867 relatively time-consuming operations like running a setup script, unpacking 868 an archive, or retrieving a URL. Using ``-q`` or ``--quiet`` drops the 869 detail level to "warn", which will only display installation reports, 870 warnings, and errors. Using ``-v`` or ``--verbose`` increases the detail 871 level to include individual file-level operations, link analysis messages, 872 and distutils messages from any setup scripts that get run. If you include 873 the ``-v`` option more than once, the second and subsequent uses are passed 874 down to any setup scripts, increasing the verbosity of their reporting as 875 well. 876 877``--dry-run, -n`` (New in 0.4a4) 878 Don't actually install the package or scripts. This option is passed down 879 to any setup scripts run, so packages should not actually build either. 880 This does *not* skip downloading, nor does it skip extracting source 881 distributions to a temporary/build directory. 882 883``--optimize=LEVEL``, ``-O LEVEL`` (New in 0.4a4) 884 If you are installing from a source distribution, and are *not* using the 885 ``--zip-ok`` option, this option controls the optimization level for 886 compiling installed ``.py`` files to ``.pyo`` files. It does not affect 887 the compilation of modules contained in ``.egg`` files, only those in 888 ``.egg`` directories. The optimization level can be set to 0, 1, or 2; 889 the default is 0 (unless it's set under ``install`` or ``install_lib`` in 890 one of your distutils configuration files). 891 892``--record=FILENAME`` (New in 0.5a4) 893 Write a record of all installed files to FILENAME. This is basically the 894 same as the same option for the standard distutils "install" command, and 895 is included for compatibility with tools that expect to pass this option 896 to "setup.py install". 897 898``--site-dirs=DIRLIST, -S DIRLIST`` (New in 0.6a1) 899 Specify one or more custom "site" directories (separated by commas). 900 "Site" directories are directories where ``.pth`` files are processed, such 901 as the main Python ``site-packages`` directory. As of 0.6a10, EasyInstall 902 automatically detects whether a given directory processes ``.pth`` files 903 (or can be made to do so), so you should not normally need to use this 904 option. It is is now only necessary if you want to override EasyInstall's 905 judgment and force an installation directory to be treated as if it 906 supported ``.pth`` files. 907 908``--no-deps, -N`` (New in 0.6a6) 909 Don't install any dependencies. This is intended as a convenience for 910 tools that wrap eggs in a platform-specific packaging system. (We don't 911 recommend that you use it for anything else.) 912 913``--allow-hosts=PATTERNS, -H PATTERNS`` (New in 0.6a6) 914 Restrict downloading and spidering to hosts matching the specified glob 915 patterns. E.g. ``-H *.python.org`` restricts web access so that only 916 packages listed and downloadable from machines in the ``python.org`` 917 domain. The glob patterns must match the *entire* user/host/port section of 918 the target URL(s). For example, ``*.python.org`` will NOT accept a URL 919 like ``http://python.org/foo`` or ``http://www.python.org:8080/``. 920 Multiple patterns can be specified by separating them with commas. The 921 default pattern is ``*``, which matches anything. 922 923 In general, this option is mainly useful for blocking EasyInstall's web 924 access altogether (e.g. ``-Hlocalhost``), or to restrict it to an intranet 925 or other trusted site. EasyInstall will do the best it can to satisfy 926 dependencies given your host restrictions, but of course can fail if it 927 can't find suitable packages. EasyInstall displays all blocked URLs, so 928 that you can adjust your ``--allow-hosts`` setting if it is more strict 929 than you intended. Some sites may wish to define a restrictive default 930 setting for this option in their `configuration files`_, and then manually 931 override the setting on the command line as needed. 932 933``--prefix=DIR`` (New in 0.6a10) 934 Use the specified directory as a base for computing the default 935 installation and script directories. On Windows, the resulting default 936 directories will be ``prefix\\Lib\\site-packages`` and ``prefix\\Scripts``, 937 while on other platforms the defaults will be 938 ``prefix/lib/python2.X/site-packages`` (with the appropriate version 939 substituted) for libraries and ``prefix/bin`` for scripts. 940 941 Note that the ``--prefix`` option only sets the *default* installation and 942 script directories, and does not override the ones set on the command line 943 or in a configuration file. 944 945``--local-snapshots-ok, -l`` (New in 0.6c6) 946 Normally, EasyInstall prefers to only install *released* versions of 947 projects, not in-development ones, because such projects may not 948 have a currently-valid version number. So, it usually only installs them 949 when their ``setup.py`` directory is explicitly passed on the command line. 950 951 However, if this option is used, then any in-development projects that were 952 installed using the ``setup.py develop`` command, will be used to build 953 eggs, effectively upgrading the "in-development" project to a snapshot 954 release. Normally, this option is used only in conjunction with the 955 ``--always-copy`` option to create a distributable snapshot of every egg 956 needed to run an application. 957 958 Note that if you use this option, you must make sure that there is a valid 959 version number (such as an SVN revision number tag) for any in-development 960 projects that may be used, as otherwise EasyInstall may not be able to tell 961 what version of the project is "newer" when future installations or 962 upgrades are attempted. 963 964 965.. _non-root installation: 966 967Custom Installation Locations 968----------------------------- 969 970By default, EasyInstall installs python packages into Python's main ``site-packages`` directory, 971and manages them using a custom ``.pth`` file in that same directory. 972 973Very often though, a user or developer wants ``easy_install`` to install and manage python packages 974in an alternative location, usually for one of 3 reasons: 975 9761. They don't have access to write to the main Python site-packages directory. 977 9782. They want a user-specific stash of packages, that is not visible to other users. 979 9803. They want to isolate a set of packages to a specific python application, usually to minimize 981 the possibility of version conflicts. 982 983Historically, there have been many approaches to achieve custom installation. 984The following section lists only the easiest and most relevant approaches [1]_. 985 986`Use the "--user" option`_ 987 988`Use the "--user" option and customize "PYTHONUSERBASE"`_ 989 990`Use "virtualenv"`_ 991 992.. [1] There are older ways to achieve custom installation using various ``easy_install`` and ``setup.py install`` options, combined with ``PYTHONPATH`` and/or ``PYTHONUSERBASE`` alterations, but all of these are effectively deprecated by the User scheme brought in by `PEP-370`_. 993 994.. _PEP-370: http://www.python.org/dev/peps/pep-0370/ 995 996 997Use the "--user" option 998~~~~~~~~~~~~~~~~~~~~~~~ 999Python provides a User scheme for installation, which means that all 1000python distributions support an alternative install location that is specific to a user [3]_. 1001The Default location for each OS is explained in the python documentation 1002for the ``site.USER_BASE`` variable. This mode of installation can be turned on by 1003specifying the ``--user`` option to ``setup.py install`` or ``easy_install``. 1004This approach serves the need to have a user-specific stash of packages. 1005 1006.. [3] Prior to the User scheme, there was the Home scheme, which is still available, but requires more effort than the User scheme to get packages recognized. 1007 1008Use the "--user" option and customize "PYTHONUSERBASE" 1009~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1010The User scheme install location can be customized by setting the ``PYTHONUSERBASE`` environment 1011variable, which updates the value of ``site.USER_BASE``. To isolate packages to a specific 1012application, simply set the OS environment of that application to a specific value of 1013``PYTHONUSERBASE``, that contains just those packages. 1014 1015Use "virtualenv" 1016~~~~~~~~~~~~~~~~ 1017"virtualenv" is a 3rd-party python package that effectively "clones" a python installation, thereby 1018creating an isolated location to install packages. The evolution of "virtualenv" started before the existence 1019of the User installation scheme. "virtualenv" provides a version of ``easy_install`` that is 1020scoped to the cloned python install and is used in the normal way. "virtualenv" does offer various features 1021that the User installation scheme alone does not provide, e.g. the ability to hide the main python site-packages. 1022 1023Please refer to the :pypi:`virtualenv` documentation for more details. 1024 1025 1026Package Index "API" 1027------------------- 1028 1029Custom package indexes (and PyPI) must follow the following rules for 1030EasyInstall to be able to look up and download packages: 1031 10321. Except where stated otherwise, "pages" are HTML or XHTML, and "links" 1033 refer to ``href`` attributes. 1034 10352. Individual project version pages' URLs must be of the form 1036 ``base/projectname/version``, where ``base`` is the package index's base URL. 1037 10383. Omitting the ``/version`` part of a project page's URL (but keeping the 1039 trailing ``/``) should result in a page that is either: 1040 1041 a) The single active version of that project, as though the version had been 1042 explicitly included, OR 1043 1044 b) A page with links to all of the active version pages for that project. 1045 10464. Individual project version pages should contain direct links to downloadable 1047 distributions where possible. It is explicitly permitted for a project's 1048 "long_description" to include URLs, and these should be formatted as HTML 1049 links by the package index, as EasyInstall does no special processing to 1050 identify what parts of a page are index-specific and which are part of the 1051 project's supplied description. 1052 10535. Where available, MD5 information should be added to download URLs by 1054 appending a fragment identifier of the form ``#md5=...``, where ``...`` is 1055 the 32-character hex MD5 digest. EasyInstall will verify that the 1056 downloaded file's MD5 digest matches the given value. 1057 10586. Individual project version pages should identify any "homepage" or 1059 "download" URLs using ``rel="homepage"`` and ``rel="download"`` attributes 1060 on the HTML elements linking to those URLs. Use of these attributes will 1061 cause EasyInstall to always follow the provided links, unless it can be 1062 determined by inspection that they are downloadable distributions. If the 1063 links are not to downloadable distributions, they are retrieved, and if they 1064 are HTML, they are scanned for download links. They are *not* scanned for 1065 additional "homepage" or "download" links, as these are only processed for 1066 pages that are part of a package index site. 1067 10687. The root URL of the index, if retrieved with a trailing ``/``, must result 1069 in a page containing links to *all* projects' active version pages. 1070 1071 (Note: This requirement is a workaround for the absence of case-insensitive 1072 ``safe_name()`` matching of project names in URL paths. If project names are 1073 matched in this fashion (e.g. via the PyPI server, mod_rewrite, or a similar 1074 mechanism), then it is not necessary to include this all-packages listing 1075 page.) 1076 10778. If a package index is accessed via a ``file://`` URL, then EasyInstall will 1078 automatically use ``index.html`` files, if present, when trying to read a 1079 directory with a trailing ``/`` on the URL. 1080