pip: Arch with python-pip: TypeError: expected string or bytes-like object

As soon as I’ve upgraded Python from 3.8 to 3.9 on Arch Linux I noticed a strange behaviour with all packages that depend on setuptools. What I’ll decribe below does NOT happen with Python 3.8 and these packages nor with Python 3.9 and packages that do not depend on setuptools. This is shy I’m reporting this issue here.

  1. Have a fresh Python 3.9 installation with no --user packages, meaning ~/.local/bin, ~/.local/lib and ~/.local/include are all empty
  2. Install a package that does not depend on setuptools, for example pip install --user vim-vint - installs OK
  3. Install the same or any other package that that does not depend on setuptools - installs OK
  4. Install any package that depends on setuptools, for example pip install --user locust - installs OK
  5. Try installing any package now - always fails with the following error
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
    status = self.run(options, args)
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/usr/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 324, in run
    requirement_set = resolver.resolve(
  File "/usr/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 331, in _get_abstract_dist_for
    skip_reason = self._check_skip_installed(req)
  File "/usr/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py", line 236, in _check_skip_installed
    req_to_install.check_if_exists(self.use_user_site)
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 437, in check_if_exists
    if not self.req.specifier.contains(existing_version, prereleases=True):
  File "/usr/lib/python3.9/site-packages/packaging/specifiers.py", line 790, in contains
    item = parse(item)
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 57, in parse
    return Version(version)
  File "/usr/lib/python3.9/site-packages/packaging/version.py", line 296, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

At this point you are unable to use pip install because it will always give the above error.

Observation: even though setuptools was originally installed in /usr/lib/python3.9/site-packages/, after we’ve installed a package that depends on setuptools it was also put in ~/.local/lib/python3.9/site-packages/.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 28 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I’m also on arch linux and have been getting this over the past couple of days. Surely it’s no coincidence that mainly arch linux users are having the problem?

All that I needed to do was install pip from source rather than from the arch repo: sudo wget https://bootstrap.pypa.io/get-pip.py -O - | python

Solution for Arch users

The way I solved this was to uninstall the offending package (setuptools):

pip uninstall setuptools

Alternatively, users can avoid using their distro-provided pip, and use pip from get-pip.py, which won’t be breakable on this manner. 😃

No worries @jaraco! I don’t know if that workflow works. I have personally used only used GUI debuggers with the debugger() callback. 😃


This is 100% because Arch is debundling pip, despite our advice to not do so in our vendoring policy. Please take this up with the Arch Linux maintainers.

Also, if someone could let them know that I’m requesting them actually vendor stuff in pip, in exchange for not breaking their users in weird ways, that’d be great! 😃