The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python FAQ. Installing Python Modules / Packages. Installing NUMPY, SCIPY, SYMPY on WINDOWS for Scientific Programming [TUTORIAL]
By Guest on 8th November 2022 01:10:46 AM | Syntax: PYTHON | Views: 187



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. Installing Python Modules
  2. *************************
  3.  
  4. Key terms
  5. =========
  6.  
  7. * "pip" is the preferred installer program. Starting with Python 3.4,
  8.   it is included by default with the Python binary installers.
  9.  
  10. * A *virtual environment* is a semi-isolated Python environment that
  11.   allows packages to be installed for use by a particular application,
  12.   rather than being installed system wide.
  13.  
  14. * "venv" is the standard tool for creating virtual environments, and
  15.   has been part of Python since Python 3.3. Starting with Python 3.4,
  16.   it defaults to installing "pip" into all created virtual
  17.   environments.
  18.  
  19. * "virtualenv" is a third party alternative (and predecessor) to
  20.   "venv". It allows virtual environments to be used on versions of
  21.   Python prior to 3.4, which either don't provide "venv" at all, or
  22.  aren't able to automatically install "pip" into created
  23.   environments.
  24.  
  25. * The Python Package Index is a public repository of open source
  26.   licensed packages made available for use by other Python users.
  27.  
  28. * the Python Packaging Authority is the group of developers and
  29.   documentation authors responsible for the maintenance and evolution
  30.   of the standard packaging tools and the associated metadata and file
  31.   format standards. They maintain a variety of tools, documentation,
  32.   and issue trackers on both GitHub and Bitbucket.
  33.  
  34. * "distutils" is the original build and distribution system first
  35.   added to the Python standard library in 1998. While direct use of
  36.   "distutils" is being phased out, it still laid the foundation for
  37.   the current packaging and distribution infrastructure, and it not
  38.   only remains part of the standard library, but its name lives on in
  39.   other ways (such as the name of the mailing list used to coordinate
  40.   Python packaging standards development).
  41.  
  42. Changed in version 3.5: The use of "venv" is now recommended for
  43. creating virtual environments.
  44.  
  45. See also:
  46.  
  47.   Python Packaging User Guide: Creating and using virtual environments
  48.  
  49.  
  50. Basic usage
  51. ===========
  52.  
  53. The standard packaging tools are all designed to be used from the
  54. command line.
  55.  
  56. The following command will install the latest version of a module and
  57. its dependencies from the Python Package Index:
  58.  
  59.    python -m pip install SomePackage
  60.  
  61. Note:
  62.  
  63.   For POSIX users (including macOS and Linux users), the examples in
  64.   this guide assume the use of a *virtual environment*.For Windows
  65.   users, the examples in this guide assume that the option to adjust
  66.   the system PATH environment variable was selected when installing
  67.   Python.
  68.  
  69. It's also possible to specify an exact or minimum version directly on
  70. the command line. When using comparator operators such as ">", "<" or
  71. some other special character which get interpreted by shell, the
  72. package name and the version should be enclosed within double quotes:
  73.  
  74.   python -m pip install SomePackage==1.0.4    # specific version
  75.   python -m pip install "SomePackage>=1.0.4"  # minimum version
  76.  
  77. Normally, if a suitable module is already installed, attempting to
  78. install it again will have no effect. Upgrading existing modules must
  79. be requested explicitly:
  80.  
  81.   python -m pip install --upgrade SomePackage
  82.  
  83. More information and resources regarding "pip" and its capabilities
  84. can be found in the Python Packaging User Guide.
  85.  
  86. Creation of virtual environments is done through the "venv" module.
  87. Installing packages into an active virtual environment uses the
  88. commands shown above.
  89.  
  90. Also see:
  91. Python Workshop - Installing Packages




  92.  
  93.  
  94. How do I ...?
  95. =============
  96.  
  97. These are quick answers or links for some common tasks.
  98.  
  99.  
  100. ... install "pip" in versions of Python prior to Python 3.4?
  101. ------------------------------------------------------------
  102.  
  103. Python only started bundling "pip" with Python 3.4. For earlier
  104. versions, "pip" needs to be "bootstrapped" as described in the Python
  105. Packaging User Guide.
  106.  
  107.  
  108. ... install packages just for the current user?
  109. -----------------------------------------------
  110.  
  111. Passing the "--user" option to "python -m pip install" will install a
  112. package just for the current user, rather than for all users of the
  113. system.
  114.  
  115.  
  116. ... install scientific Python packages?
  117. ---------------------------------------
  118.  
  119. A number of scientific Python packages have complex binary
  120. dependencies, and aren't currently easy to install using "pip"
  121. directly. At this point in time, it will often be easier for users to
  122. install these packages by other means rather than attempting to
  123. install them with "pip".
  124.  
  125. Help reference:
  126. Installing PYTHON and NUMPY, SCIPY, SYMPY on WINDOWS for Scientific Programming [TUTORIAL]
  127. https://www.youtube.com/watch?v=-S0EULmh-ZQ
  128.  
  129.  
  130.  
  131. ... work with multiple versions of Python installed in parallel?
  132. ----------------------------------------------------------------
  133.  
  134. On Linux, macOS, and other POSIX systems, use the versioned Python
  135. commands in combination with the "-m" switch to run the appropriate
  136. copy of "pip":
  137.  
  138.    python2   -m pip install SomePackage  # default Python 2
  139.    python2.7 -m pip install SomePackage  # specifically Python 2.7
  140.    python3   -m pip install SomePackage  # default Python 3
  141.    python3.4 -m pip install SomePackage  # specifically Python 3.4
  142.  
  143. Appropriately versioned "pip" commands may also be available.
  144.  
  145. On Windows, use the "py" Python launcher in combination with the "-m"
  146. switch:
  147.  
  148.    py -2   -m pip install SomePackage  # default Python 2
  149.    py -2.7 -m pip install SomePackage  # specifically Python 2.7
  150.    py -3   -m pip install SomePackage  # default Python 3
  151.    py -3.4 -m pip install SomePackage  # specifically Python 3.4
  152.  
  153.  
  154. Common installation issues
  155. ==========================
  156.  
  157.  
  158. Installing into the system Python on Linux
  159. ------------------------------------------
  160.  
  161. On Linux systems, a Python installation will typically be included as
  162. part of the distribution. Installing into this Python installation
  163. requires root access to the system, and may interfere with the
  164. operation of the system package manager and other components of the
  165. system if a component is unexpectedly upgraded using "pip".
  166.  
  167. On such systems, it is often better to use a virtual environment or a
  168. per-user installation when installing packages with "pip".
  169.  
  170.  
  171. Pip not installed
  172. -----------------
  173.  
  174. It is possible that "pip" does not get installed by default. One
  175. potential fix is:
  176.  
  177.    python -m ensurepip --default-pip
  178.  
  179. There are also additional resources for installing pip.
  180.  
  181.  
  182. [inline]
















Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.

Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.

See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license
  • Recent Pastes