Did something happen to pip?

Hello, I have recently tried to add new python libraries to my system via pip, which used to work.

Now, simply entering the command pip or sudo pip into the terminal greets me with the following error:

Traceback (most recent call last):

  File "/usr/bin/pip", line 33, in <module>
    sys.exit(load_entry_point('pip==20.3.4', 'console_scripts', 'pip')())
  File "/usr/bin/pip", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/usr/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/usr/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 34, in <module>
    from pip._internal.locations import get_major_minor_version, site_packages, user_site
  File "/usr/lib/python3.9/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
    from . import _distutils, _sysconfig
  File "/usr/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
    from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/usr/lib/python3.9/site-packages/pip/_internal/exceptions.py)

Any suggestions? I have tried reinstalling pip.

Tip: When pasting terminal output on Discourse forums, one can either…

  • Highlight it and use the Preformatted text </> toolbar button.

  • Add three backticks ` above and below the text (Markdown):

    ```
    text
    ```

  • Use HTML:

    <pre><code>
    text
    </pre></code>

Please edit your post accordingly.

Somebody else reported similar issues a while ago:

I have pip installed as well. Mine is working fine at the moment.

~ >>> pip --version                                                                                                                                                                                                 
pip 20.3.4 from /usr/lib/python3.9/site-packages/pip (python 3.9)

Can you tell us what has changed there? Most likely, something has changed on your end and it would be nice to figure that out.

Just a reminder on how to provide good information below, If you haven’t checked that out already :slightly_smiling_face:

I tried to install pyserial, but got this error immediately and it didn’t work. Other than that, it has been a couple of months since I installed anything from pip on initial setup of the machine.

I forgot to mention: Don’t do that. Use system packages or use a virtual environment for development.

2 Likes

What’s meant by system packages? sudo pip? Or would that mean getting it from the manjaro repo?

Excactly.

NEVER do that.

1 Like
~ >>> pacman -Si python-pyserial                                                                                                                                                                                 [1]
Repository      : community
Name            : python-pyserial
Version         : 3.5-2
Description     : Multiplatform Serial Port Module for Python
Architecture    : any
URL             : https://github.com/pyserial/pyserial
Licenses        : custom:PYTHON
Groups          : None
Provides        : None
Depends On      : python
Optional Deps   : None
Conflicts With  : None
Replaces        : None
Download Size   : 128.48 KiB
Installed Size  : 527.80 KiB
Packager        : Morten Linderud <foxboron@archlinux.org>
Build Date      : Wed 17 Mar 2021 05:17:59 PM CDT
Validated By    : MD5 Sum  SHA-256 Sum  Signature

Would that package work for you? :slightly_smiling_face:

1 Like

Thank You!

You didn’t have to do that,
I really do appreciate it.

I have a lot of things that I would have installed with apt on single board computers that I use pip for now. Package names are sometimes different. I should take the time to find them and update my own stuff.

That said, I would still like pip to work.
It’s useful sometimes.

I did find at least one other recent thread with a similar issue and it’s also unresloved.

Maybe it will be fixed randomly in a future update, otherwise if I figure it out, I will let you guys know.

Edit: I already had it installed anyway. LOL :laughing:

If you just want to run a script with specific dependencies then you are better off to use virtualenv (pkg: python-virtualenv)

virtualenv ~/my-python-env

and activate it:

source ~/my-python-env/bin/activate

Then install all dependencies you need with pip.

Otherwise better install system libraries for python though the package manager as suggested.

4 Likes

Just a note, I deleted pip manually by hunting down some files in /usr/lib/python3.9/site-packages .egg-info relating to pip, as well as a directory called pip, then I ran sudo pacman -Rns python-pip.

Followed by sudo pacman -S python-pip.

I should also add that I cleared the pacman cache

Now it’s working.

Oh, and to all of you who suggest using virtual environments… I figured it out. It’s not too annoying to do.

It even seems to work in VS code. Thanks for the good advice!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.