You are not logged in.

#1 2023-08-22 12:10:06

guiodic
Member
Registered: 2018-02-22
Posts: 23

[SOLVED][NOT A BUG] Pip list shows packages installed systemwide

Hi, i deleted manually all the packages in /home/guido/.local/lib/python3.11/site-packages/
because pip uninstall says I can't do it

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

But now pip list keeps returning me the installed packages--what can I do?

Last edited by guiodic (2023-08-22 14:46:34)

Offline

#2 2023-08-22 12:45:05

silensys
Member
Registered: 2023-08-21
Posts: 2

Re: [SOLVED][NOT A BUG] Pip list shows packages installed systemwide

If you're speaking about this error message, its not a list of any python package but a warning message.

Could you please double check and confirm if you're really geting any output of your custom installed (so exluding the default ones) python packages by running

pip list

You don't have to paste the output here, since even installed packages can be sensitive data as well.

Normally, for security and to not accidentally break Arch reasons, as stated in the error message you've got, python pip suggests you to use virtual enviroment instead.

If you're sourced inside of the venv (see the link for further details I provided above), you can install and uninstall pip programs freely, without that warning message, because you're "isolated" from the global python enviroment, making sure to work in an "isolated sandbox", to not accidentally break any key component of the distro. If you're sourced, all the python commands you use are strictly tied for this specific enviroment. You could think of it as an explosion proof laboratory, inside a laboratory, you can freely experiment while not affecting anything outside of the enviroment.

If you've got no virtual env beofre, chances are that you've successfully got rid of any custom installed packages by removing the site-packages directory, you've mentioned.

Last edited by silensys (2023-08-22 12:54:15)


"This is the way"

Offline

#3 2023-08-22 13:02:14

guiodic
Member
Registered: 2018-02-22
Posts: 23

Re: [SOLVED][NOT A BUG] Pip list shows packages installed systemwide

silensys wrote:

Could you please confirm if you get any output by running

pip list

Yes, it returs a list of packages.

Anyway, it seems they are packages installed system-wide in /usr/lib/python3.11/site-packages

$ pip freeze | awk -F "==" '{ print $1 }' | xargs pip show | grep Location

Location: /usr/lib/python3.11/site-packages
.... long list of identical rows like this

while pip list --user give nothing.

Is that correct?

I presumed pip shows only packages installed with pip itself.

Offline

#4 2023-08-22 13:37:41

silensys
Member
Registered: 2023-08-21
Posts: 2

Re: [SOLVED][NOT A BUG] Pip list shows packages installed systemwide

guiodic wrote:
silensys wrote:

Could you please confirm if you get any output by running

pip list

Yes, it returs a list of packages.

Anyway, it seems they are packages installed system-wide in /usr/lib/python3.11/site-packages

$ pip freeze | awk -F "==" '{ print $1 }' | xargs pip show | grep Location

Location: /usr/lib/python3.11/site-packages
.... long list of identical rows like this

while pip list --user give nothing.

Is that correct?

I presumed pip shows only packages installed with pip itself.

Yepp, the list you've got is system wide, so don't "hurt" those files smile
Also, your observation about pip list --user is correct. It won't show any packages because it focuses on packages that were installed with the --user flag (pip install --user <pkgname>), which generally aren't displayed by the standard pip list command.

Instead, use:

pip freeze --local

pip freeze --local: This command lists all packages installed in the current environment, including their versions. It's typically used to generate a requirements file for replicating the environment elsewhere. It only lists packages directly installed in your environment and not their dependencies.

pip list --local: This command also lists packages installed in the current environment, but it includes their dependencies as well. So, it might show a larger number of packages since it accounts for both the packages you installed and the ones that were installed as dependencies.

Now about this list, what I experienced and observed is that it lists not only pip installed packages but also lists pacman installed packages as well!
For example: I've installed "yt-dlp" through pacman, and both pip freeze --local and pip list --local lists it smile

Last edited by silensys (2023-08-22 13:39:44)


"This is the way"

Offline

#5 2023-08-22 14:45:35

guiodic
Member
Registered: 2018-02-22
Posts: 23

Re: [SOLVED][NOT A BUG] Pip list shows packages installed systemwide

Ok, thank you, so it's all ok.

Best!

Offline

Board footer

Powered by FluxBB