Показать установленные пакеты python

Where Does pip Install Packages

To see where pip installs packages on your system, run the following command:

And replace with the actual name of the package.

Example: NumPy Location

For example, let’s see where NumPy is installed:

Name: numpy Version: 1.22.2 Summary: NumPy is the fundamental package for array computing with Python. Home-page: https://www.numpy.org Author: Travis E. Oliphant et al. Author-email: None License: BSD Location: /usr/local/lib/python3.8/site-packages Requires: Required-by: torchvision, perfplot, opencv-python, matplotx, DALL-E, benchit

Here you can see that the location field says the package is installed at /usr/local/lib/python3.8/site-packages.

The location obviously depends on your system and Python version.

How to View All pip Package Locations

To list all the installed package locations, run the following command:

This spits out a huge list of different packages and their locations:

alabaster 0.7.8 /usr/lib/python3/dist-packages apparmor 2.13.3 /usr/lib/python3/dist-packages appdirs 1.4.3 /usr/lib/python3/dist-packages apturl 0.5.2 /usr/lib/python3/dist-packages .

Now you understand how to check the pip package locations using the command line/terminal.

Читайте также:  Python объединить два файла

Next, let’s take a look at how you can find this information using a Python script.

How to View pip Package Location in Python Script?

In addition to using the command line to figure out the location of packages installed via pip, you can run a Python script to get the information.

There are two ways to do this:

The site Module

To find the general location of pip packages in a Python script:

  1. Import the site package.
  2. Call the getsitepackages() function of the module.
  3. See a list of global package locations.

Here is how it looks in code:

>>> import site >>> site.getsitepackages() ['/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.8/dist-packages']

And to get a user-specific package location as a string, call the getusersitepackages() function instead.

The help() Function

Of course, you can always use the help() function to get all kinds of information about any Python package or object.

This also shows you the location where the package is installed.

For example, lets’ see where the pandas package is installed:

>>> import pandas >>> help(pandas)

Running this piece of code opens up the package-specific manual.

If you scroll all the way down to the end of this output, you can see the FILE section where it shows you the path of the package.

pip install location pandas

By the way, in case you happen to be unfamiliar with the help() function in Python, I highly recommend you read this article. Using help() can help you a lot and save valuable coding time!

About the Author

Hi, I’m Artturi Jalli!

I’m a Tech enthusiast from Finland.

I make Coding & Tech easy and fun with well-thought how-to guides and reviews.

I’ve already helped 5M+ visitors reach their goals!

ChatGPT Review (and How to Use It)—A Full Guide (2023)

ChatGPT is the newest Artificial Intelligence language model developed by OpenAI. Essentially, ChatGPT is an AI-based chatbot that can answer any question. It understands complex topics, like.

10 Best AI Art Generators of 2023 (Reviewed & Ranked)

Choosing the right type of AI art generator is crucial to produce unique, original, and professional artwork. With the latest advancements in AI art generation, you can.

How to Make an App — A Complete 10-Step Guide (in 2023)

Are you looking to create the next best-seller app? Or are you curious about how to create a successful mobile app? This is a step-by-step guide on.

9 Best Graphic Design Courses + Certification (in 2023)

Do you want to become a versatile and skilled graphic designer? This is a comprehensive article on the best graphic design certification courses. These courses prepare you.

8 Best Python Courses with Certifications (in 2023)

Are you looking to become a professional Python developer? Or are you interested in programming but don’t know where to start? Python is a beginner-friendly and versatile.

8 Best Swift & iOS App Development Courses [in 2023]

Are you looking to become an iOS developer? Do you want to create apps with an outstanding design? Do you want to learn to code? IOS App.

Источник

pip list#

List installed packages, including editables. Packages are listed in a case-insensitive sorted order.

Options#

-o , —outdated # List outdated packages -u , —uptodate # List uptodate packages -e , —editable # List editable projects. -l , —local # If in a virtualenv that has global access, do not list globally-installed packages. —user # Only output packages installed in user-site. —path # Restrict to the specified installation path for listing packages (can be used multiple times). —pre # Include pre-release and development versions. By default, pip only finds stable versions. —format # Select the output format among: columns (default), freeze, or json. The ‘freeze’ format cannot be used with the —outdated option. —not-required # List packages that are not dependencies of installed packages. —exclude-editable # Exclude editable package from output. —include-editable # Include editable package from output. —exclude # Exclude specified package from the output -i , —index-url # Base URL of the Python Package Index (default https://pypi.org/simple). This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format. —extra-index-url # Extra URLs of package indexes to use in addition to —index-url. Should follow the same rules as —index-url. —no-index # Ignore package index (only looking at —find-links URLs instead). -f , —find-links # If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files. If a local path or file:// URL that’s a directory, then look for archives in the directory listing. Links to VCS project URLs are not supported.

Examples#

$ python -m pip list Package Version ------- ------- docopt 0.6.2 idlex 1.13 jedi 0.9.0 
C:\> py -m pip list Package Version ------- ------- docopt 0.6.2 idlex 1.13 jedi 0.9.0 
$ python -m pip list --outdated --format columns Package Version Latest Type ---------- ------- ------ ----- retry 0.8.1 0.9.1 wheel setuptools 20.6.7 21.0.0 wheel 
C:\> py -m pip list --outdated --format columns Package Version Latest Type ---------- ------- ------ ----- retry 0.8.1 0.9.1 wheel setuptools 20.6.7 21.0.0 wheel 
$ python -m pip list --outdated --not-required Package Version Latest Type -------- ------- ------ ----- docutils 0.14 0.17.1 wheel 
C:\> py -m pip list --outdated --not-required Package Version Latest Type -------- ------- ------ ----- docutils 0.14 0.17.1 wheel 
$ python -m pip list --format=json [, , . 
C:\> py -m pip list --format=json [, , . 
$ python -m pip list --format=freeze colorama==0.3.7 docopt==0.6.2 idlex==1.13 jedi==0.9.0 
C:\> py -m pip list --format=freeze colorama==0.3.7 docopt==0.6.2 idlex==1.13 jedi==0.9.0 

When some packages are installed in editable mode, pip list outputs an additional column that shows the directory where the editable project is located (i.e. the directory that contains the pyproject.toml or setup.py file).

$ python -m pip list Package Version Editable project location ---------------- -------- ------------------------------------- pip 21.2.4 pip-test-package 0.1.1 /home/you/.venv/src/pip-test-package setuptools 57.4.0 wheel 0.36.2 
C:\> py -m pip list Package Version Editable project location ---------------- -------- ---------------------------------------- pip 21.2.4 pip-test-package 0.1.1 C:\Users\You\.venv\src\pip-test-package setuptools 57.4.0 wheel 0.36.2 

The json format outputs an additional editable_project_location field.

$ python -m pip list --format=json | python -m json.tool [   "name": "pip", "version": "21.2.4", >,   "name": "pip-test-package", "version": "0.1.1", "editable_project_location": "/home/you/.venv/src/pip-test-package" >,   "name": "setuptools", "version": "57.4.0" >,   "name": "wheel", "version": "0.36.2" > ] 
C:\> py -m pip list --format=json | py -m json.tool [   "name": "pip", "version": "21.2.4", >,   "name": "pip-test-package", "version": "0.1.1", "editable_project_location": "C:\Users\You\.venv\src\pip-test-package" >,   "name": "setuptools", "version": "57.4.0" >,   "name": "wheel", "version": "0.36.2" > ] 

Contrary to the freeze command, pip list —format=freeze will not report editable install information, but the version of the package at the time it was installed.

Источник

pip show#

Show information about one or more installed packages. The output is in RFC-compliant mail header format.

Options#

Examples#

$ python -m pip show sphinx Name: Sphinx Version: 1.4.5 Summary: Python documentation generator Home-page: http://sphinx-doc.org/ Author: Georg Brandl Author-email: georg@python.org License: BSD Location: /my/env/lib/python2.7/site-packages Requires: docutils, snowballstemmer, alabaster, Pygments, imagesize, Jinja2, babel, six 
C:\> py -m pip show sphinx Name: Sphinx Version: 1.4.5 Summary: Python documentation generator Home-page: http://sphinx-doc.org/ Author: Georg Brandl Author-email: georg@python.org License: BSD Location: /my/env/lib/python2.7/site-packages Requires: docutils, snowballstemmer, alabaster, Pygments, imagesize, Jinja2, babel, six 
$ python -m pip show --verbose sphinx Name: Sphinx Version: 1.4.5 Summary: Python documentation generator Home-page: http://sphinx-doc.org/ Author: Georg Brandl Author-email: georg@python.org License: BSD Location: /my/env/lib/python2.7/site-packages Requires: docutils, snowballstemmer, alabaster, Pygments, imagesize, Jinja2, babel, six Metadata-Version: 2.0 Installer: Classifiers: Development Status :: 5 - Production/Stable Environment :: Console Environment :: Web Environment Intended Audience :: Developers Intended Audience :: Education License :: OSI Approved :: BSD License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 3 Framework :: Sphinx Framework :: Sphinx :: Extension Framework :: Sphinx :: Theme Topic :: Documentation Topic :: Documentation :: Sphinx Topic :: Text Processing Topic :: Utilities Entry-points: [console_scripts] sphinx-apidoc = sphinx.apidoc:main sphinx-autogen = sphinx.ext.autosummary.generate:main sphinx-build = sphinx:main sphinx-quickstart = sphinx.quickstart:main [distutils.commands] build_sphinx = sphinx.setup_command:BuildDoc 
C:\> py -m pip show --verbose sphinx Name: Sphinx Version: 1.4.5 Summary: Python documentation generator Home-page: http://sphinx-doc.org/ Author: Georg Brandl Author-email: georg@python.org License: BSD Location: /my/env/lib/python2.7/site-packages Requires: docutils, snowballstemmer, alabaster, Pygments, imagesize, Jinja2, babel, six Metadata-Version: 2.0 Installer: Classifiers: Development Status :: 5 - Production/Stable Environment :: Console Environment :: Web Environment Intended Audience :: Developers Intended Audience :: Education License :: OSI Approved :: BSD License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 3 Framework :: Sphinx Framework :: Sphinx :: Extension Framework :: Sphinx :: Theme Topic :: Documentation Topic :: Documentation :: Sphinx Topic :: Text Processing Topic :: Utilities Entry-points: [console_scripts] sphinx-apidoc = sphinx.apidoc:main sphinx-autogen = sphinx.ext.autosummary.generate:main sphinx-build = sphinx:main sphinx-quickstart = sphinx.quickstart:main [distutils.commands] build_sphinx = sphinx.setup_command:BuildDoc 

Источник

Оцените статью