Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List only system packages (excluding those installed with --user) with pip list #4809

Closed
tuukkamustonen opened this issue Oct 25, 2017 · 6 comments
Labels
auto-locked Outdated issues that have been locked by automation C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality

Comments

@tuukkamustonen
Copy link

tuukkamustonen commented Oct 25, 2017

  • Pip version: 8.1.1
  • Python version: 2.7
  • Operating system: Ubuntu 16.04

pip list lists a combination of system-wide and user-scoped packages (in ~/.local). There is pip list --user to list only the packages installed with --user flag, but it's not possible to do the listing the other way around, to list only packages installed under /usr/lib/.

Currently, if the same package is installed as both system-wide and as user-scoped, then only user-scoped package wins and pip list shows details for that. It's not possible to see what version is installed as system-wide.

Consider adding pip list --system (as opposed to pip list --user).

(Related, there is no pip uninstall --user or pip uninstall --system, to indicate which package to uninstall. Though I think this deserves a separate ticket.)

@tuukkamustonen tuukkamustonen changed the title List system packages with pip list List only system packages (excluding those installed with --user) with pip list Oct 25, 2017
@pradyunsg pradyunsg added type: enhancement Improvements to functionality C: list/show 'pip list' or 'pip show' labels Oct 25, 2017
@pradyunsg
Copy link
Member

pradyunsg commented Oct 25, 2017

I think pip list provides everything you'd need to do this by processing the output of pip list now -- there's a location key and pip list -v --format=json gives you, well, JSON output.

As an aside, there's #4575 which should probably help with what you're asking for.

I'll defer to other @pypa/pip-committers to figure out and decide if there's something actionable here.

@tuukkamustonen
Copy link
Author

On a side note: looks like I'm actually running 8.1.1 and not 9.0.1. I have:

10:36 $ dpkg -l | grep -i python-pip
ii  python-pip                                      8.1.1-2ubuntu0.4                                         all          alternative Python package installer

I thought I upgraded pip locally but looks like local pip command resort to system-wide package for execution:

$ pip install --user pip\>9
Collecting pip>9
  Downloading https://pypi/root/pypi/+f/297/dbd16ef53bcef/pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 1.3MB/s 
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip --version
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ ~/.local/bin/pip --version
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ ls ~/.local/lib/python2.7/site-packages/pip<TAB>
pip/                 pip-9.0.1.dist-info/ 

Updating original message to reflect that I'm actually not running the latest version...

@pradyunsg
Copy link
Member

pradyunsg commented Oct 25, 2017

The issue here is probably that you don't have ~/.local/bin on your PATH or maybe that you have some pip, pip2, pip3 conflicts.

There's a patch in pip 10 that helps with the former by printing a warning when you install a script outside of PATH.

(edited)

@tuukkamustonen
Copy link
Author

I do have ~/.local/bin in PATH but even invoking the command directly didn't work:

$ ~/.local/bin/pip --version
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Anyway, I think I just faced #3776 and related. Let's ignore that for now.

@tuukkamustonen
Copy link
Author

I think #4575 is indeed a superset of what I'm suggesting here. Closing this one in favor of that one!

@pradyunsg
Copy link
Member

Cool. :)

Thanks for filing this issue.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

2 participants