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?
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
.
update pip using code bellow
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
I can try to fix it with pip install request --upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With