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).
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
pip freeze
will output a list of installed packages and their versions. It also allows you to write those packages to a file that can later be used to set up a new environment.https://pip.pypa.io/en/stable/reference/pip_freeze/#pip-freeze
Newer versions of pip have the ability to do what the OP wants via pip list -l or pip freeze -l. On Debian (at least) the man page doesn't make this clear, and I only discovered it - under the assumption that the feature must exist - with pip list --help.
There are recent comments that suggest this feature is not obvious in either the documentation or the existing answers (although hinted at by some), so I thought I should post. I would have preferred to do so as a comment, but I don't have the reputation points.
Take note that if you have multiple versions of Python installed on your computer, you may have a few versions of pip associated with each.
Depending on your associations, you might need to be very cautious of what pip command you use:
Worked for me, where I'm running Python3.4. Simply using
pip list
returned the errorThe program 'pip' is currently not installed. You can install it by typing: sudo apt-get install python-pip
.If anyone is wondering you can use the 'pip show' command.
This will list the install directory of the given package.
The below is a little slow, but it gives a nicely formatted list of packages that
pip
is aware of. That is to say, not all of them were installed "by" pip, but all of them should be able to be upgraded by pip.The reason it is slow is that it lists the contents of the entire pypi repo. I filed a ticket suggesting
pip list
provide similar functionality but more efficiently.Sample output: (restricted the search to a subset instead of '.' for all.)
pip.get_installed_distributions()
will give a list of installed packages