question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] pkg_resources old version of pyparsing breaks pip in 3.10.0 and 3.10.1 on Linux

See original GitHub issue

setuptools version

setuptools===60.2.0

Python version

Python 3.10

OS

Ubuntu 18.04

Additional environment information

Installed python 3.10 on Ubuntu using “sudo apt install python3.10”

Description

After installing Python 3.10, running “python3.10 -m pip” gives this error.

$ python3.10 -m pip
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 73, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 77, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/extern/__init__.py", line 43, in load_module
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/pyparsing.py", line 943, in <module>

AttributeError: module 'collections' has no attribute 'MutableMapping'

After looking at the contents of the pkg_resources /_vendor/ directory, I see that pyparsing is at version 2.1.10.

I tried upgrading setuptools by downloading the source package for 60.2.0 and running “sudo python3.10 setup.py install”. This installation appeared to succeed, but I still have the same error when doing “python3.10 -m pip”.

How can I replace the old vendored pyparsing with a new py3.10-compatible version? (2.2.1 would do the trick).

Expected behavior

No error

How to Reproduce

<install on Ubuntu - I believe other Linuxes also have issues> $ python3.10 -m pip

Output

pmcguire@pmcguire-py:/tmp/setuptools-60.2.0$ python3.10 -m pip
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 73, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 77, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/extern/__init__.py", line 43, in load_module
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/pyparsing.py", line 943, in <module>

AttributeError: module 'collections' has no attribute 'MutableMapping'

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Niccolumcommented, Jan 8, 2022

According previous issue, next steps solve problem:

  • add deadsnake repo (default or nightly)
  • sudo apt install python3.10
  • git clone git@github.com:pypa/setuptools.git && cd setuptools && python3.10 setup.py install
  • sudo apt install python3.10-distutils
  • curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

Don’t know, is it needed to clone setuptools and install this locally for solving problem. Just my steps. @ptmcg

UPD: @ptmcg can you add this info in SO? I haven’t SO acc yet.

2reactions
jaracocommented, Jan 8, 2022

I created this dockerfile to bootstrap pip:

FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN apt-add-repository -y ppa:deadsnakes
RUN apt update
RUN apt install -y build-essential curl git python3.10 python3.10-distutils
RUN curl -Ss https://bootstrap.pypa.io/get-pip.py | python3.10
RUN python3.10 -m pip install path

And it runs to completion. From there, you can pip install setuptools. Maybe that helps?

If I leave out python3.10-distutils, then the pip invocation fails when distutils.cmd doesn’t exist (different error than reported above). That seems to coincide with the answer in the pip issue.

In any case, hope that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting AttributeError: module 'collections' has no attribute ...
The problem is caused by an old version of pyparsing that has been vendored into pkg_resources , which is now part of setuptools...
Read more >
Changelog - pip documentation v22.3.1
Explains why specified version cannot be retrieved when Requires-Python is ... in vendored tenacity to prevent old versions of Tornado from breaking pip....
Read more >
Pip Can't Install package or show package after Upgrade to ...
I try to upgrade from Python 3.6 to 3.10 then pip can't list packages nor ... line 9, in <module> from pkg_resources.extern.pyparsing import ......
Read more >
Installing scikit-learn
Install the version of scikit-learn provided by your operating system or Python distribution. This is a quick option for those who have operating...
Read more >
attributeerror module 'collections' has no attribute ... - You.com
pipenv install --python /usr/bin/python3.10 Creating a virtualenv for this ... by an old version of pyparsing that has been vendored into pkg_resources, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found