39

Hey I have installed latest python 3.10 and pip3 on my linux (Zorin os lite 15.3 X64) machine but whenever I try to use any pip3 command I get following error For example I use the command:

pip3 freeze

I get the following error:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  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'

This was working fine with python 3.9 but when I updated to 3.10 I started getting this error. How can I solve this?

3
  • Were you able to finally resolve this for yourself? Updating Python to 3.10.1 did not help. Commented Dec 31, 2021 at 1:11
  • No, I switched back to version 3.9 Commented Jan 1, 2022 at 8:45
  • Please see update below - I think we have a solution (or at least a workaround). Commented Jan 8, 2022 at 21:09

6 Answers 6

37

The problem is caused by an old version of pyparsing that has been vendored into pkg_resources, which is now part of setuptools.

I think if you install an updated setuptools, things will run better:

python -m pip install -U setuptools

EDIT - After installing my own version of 3.10.1 on Ubuntu 18.04, I am having this same issue. And the broken pkg_resources is preventing doing any updates, so your classic Catch-22. To begin chasing down a resolution, I've submitted a ticket on the setuptools Github repo.

EDIT2 - Based on aid on the setuptools GitHub repo, I did the following steps:

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

At this point, I am able to run pip in Python3.10, and create venvs using python3.10 -m venv virtualenv-dir.

Sign up to request clarification or add additional context in comments.

9 Comments

Did this work for anyone? I am using python 3.10 installed via pyenv, and it did not work for me. I am also using pipenv in my enviroment if that makes a difference.
pkg_resources imports packaging, which imports pyparsing. The pyparsing 3.0.5 release included breaking API changes, which were refactored back in in pyparsing 3.0.6. If still not working after updating to pyparsing 3.0.6, please post an issue on pyparsing's GitHub.
Packaging 21.3 just got pushed to pypi, compatible with the latest pyparsing, so I think these issues should all be sorted if upgrade to latest of both packages.
@AugustineCalvino - I am seeing this issue now on Ubuntu, working on it. Were you able to resolve?
Solves the error for python3.10 on Ubuntu18
|
33

update pip using code bellow

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

1 Comment

You may need to do: sudo apt-get install python3.10-distutils if you get the error: ModuleNotFoundError: No module named 'distutils.cmd'
8

"Do not install pipenv from apt, it's way too old. Install from pypi." source: https://github.com/pypa/pipenv/issues/5469

This solve it for me:

sudo apt remove pipenv
pip install pipenv

Unfortunately pipenvdidn't worked out of the box in this console. I had to use:

python -m pipenv

Or simply start a new terminal session.

Comments

1

I can try to fix it with pip install request --upgrade

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

On Linux mint

sudo apt remove pipenv
pip3 install pipenv

or

sudo apt install pipenv

Comments

-5

Update pip...collections.MutableMapping has become collections.abc.MutableMapping.

2 Comments

Actually you want to update python wheel. If you run into any other issues, the first thing to do is to update to the latest package versions from pypi.
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.