'update-alternatives: warning: force to reinstall /usr/local/bin/pip3.10 because pip linkgroup is invalid

I got following message when I try to do something with pip.

      Wybór       Ścieżka               Priorytet  Status
    ------------------------------------------------------------
      0            /usr/local/bin/pip3.10   1         tryb auto
    * 1            /usr/local/bin/pip3.10   1         tryb ręczny
      2            /usr/local/bin/pip3.9    1         tryb ręczny
    
    Proszę wcisnąć <enter>, aby pozostawić bieżący wybór[*]; albo wpisać wybrany numer: 0
    update-alternatives: warning: force to reinstall /usr/local/bin/pip3.10 because pip linkgroup is invalid 
update-alternatives: warning: skip replacing / usr / bin / pip with link

Tried to reinstall pip with: sudo apt-get --purge autoremove python-pip then sudo apt-get install python-pip

Also tried to change a link with update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1 -path is correct.

If I use python -V && pip -V:

Python 3.10.4
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'

How can I fix so my pip is connected to /usr/local/bin/pip3.10 so I can install packages?



Solution 1:[1]

So apparently now with new debian and new Python we should no longer use pip install ... but python -m pip install.... There is warning from pip.

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Patryk