Find all packages installed with easy_install/pip?

2020-01-24 18:39发布

Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tools (in this case apt-get on Debian).

18条回答
\"骚年 ilove
2楼-- · 2020-01-24 18:55

As of version 1.3 of pip you can now use pip list

It has some useful options including the ability to show outdated packages. Here's the documentation: https://pip.pypa.io/en/latest/reference/pip_list/

查看更多
Luminary・发光体
3楼-- · 2020-01-24 18:55

Start with:

$ pip list

To list all packages. Once you found the package you want, use:

$ pip show <package-name>

This will show you details about this package, including its folder. You can skip the first part if you already know the package name

Click here for more information on pip show and here for more information on pip list.

Example:

$ pip show jupyter
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
License: BSD
Location: /usr/local/lib/python2.7/site-packages
Requires: ipywidgets, nbconvert, notebook, jupyter-console, qtconsole, ipykernel    
查看更多
在下西门庆
4楼-- · 2020-01-24 18:59

pip freeze lists all installed packages even if not by pip/easy_install. On CentOs/Redhat a package installed through rpm is found.

查看更多
乱世女痞
5楼-- · 2020-01-24 18:59

pip list [options] You can see the complete reference here

查看更多
姐就是有狂的资本
6楼-- · 2020-01-24 19:01

Adding to @Paul Woolcock's answer,

$ pip freeze > requirements.txt

will create a requirements file with all installed packages in the active environment at the current location which you can run

$ pip install -r requirements.txt

to install the requirements at another environment.

查看更多
可以哭但决不认输i
7楼-- · 2020-01-24 19:01

At least for Ubuntu (maybe also others) works this (inspired by a previous post in this thread):

printf "Installed with pip:";
pip list 2>/dev/null | gawk '{print $1;}' | while read; do pip show "${REPLY}" 2>/dev/null | grep 'Location: /usr/local/lib/python2.7/dist-packages' >/dev/null; if (( $? == 0 )); then printf " ${REPLY}"; fi; done; echo
查看更多
登录 后发表回答