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

TypeError: expected string or bytes-like object when installing pip packages #9466

Closed
JordanKadish opened this issue Jan 17, 2021 · 1 comment
Labels
resolution: duplicate Duplicate of an existing issue/PR

Comments

@JordanKadish
Copy link

Environment

  • pip version: 20.2.4
  • Python version: 3.9
  • OS: Arch Linux

Description

When running any pip install command, I run into this error unless I run the install as super user
Expected behavior

the module installs
How to Reproduce

pip install <requests, pylint, etc>

Output

$ pip install requests
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 228, 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 323, 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 438, 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

A solution I have seen posted online is to replace the regex search version line with self._regex.search(str(version))

@uranusjr
Copy link
Member

See #9348. TL;DR This is an Arch issue (more specifically, Arch’s modification to their pip package).

@uranusjr uranusjr added the resolution: duplicate Duplicate of an existing issue/PR label Jan 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

2 participants