[BUG] pkg_resources old version of pyparsing breaks pip in 3.10.0 and 3.10.1 on Linux
See original GitHub issuesetuptools 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:
- Created 2 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
According previous issue, next steps solve problem:
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.
I created this dockerfile to bootstrap pip:
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 whendistutils.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.