I try to upgrade from Python 3.6 to 3.10 then pip can’t list packages nor install any package.
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
apt list | grep python3.10
sudo apt-get install python3.10
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
sudo update-alternatives --config python3
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
I put this on my .bashrc:
alias pip310='python3.10 -m pip'
When I type pip310 list
, get error:
Keyring is skipped due to an exception: module 'collections' has no attribute 'MutableMapping'
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/commands/list.py", line 166, in run
for d in get_environment(options.path).iter_installed_distributions(
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/metadata/__init__.py", line 85, in get_environment
return select_backend().Environment.from_paths(paths)
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/metadata/__init__.py", line 63, in select_backend
from . import pkg_resources
File "/usr/local/lib/python3.10/dist-packages/pip/_internal/metadata/pkg_resources.py", line 8, in <module>
from pip._vendor import pkg_resources
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3252, in <module>
def _initialize_master_working_set():
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3235, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3277, in _initialize_master_working_set
tuple(
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3278, in <genexpr>
dist.activate(replace=False)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2785, in activate
declare_namespace(pkg)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2284, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2217, in _handle_ns
loader.load_module(packageName)
File "/usr/lib/python3/dist-packages/mpl_toolkits/__init__.py", line 2, in <module>
__import__('pkg_resources').declare_namespace(__name__)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 77, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
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/lib/python3/dist-packages/pkg_resources/extern/__init__.py", line 43, in load_module
__import__(extant)
File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 943, in <module>
collections.MutableMapping.register(ParseResults)
AttributeError: module 'collections' has no attribute 'MutableMapping'
Another question: How to Uninstall the previous Python 3.6? So I only have Python 3.10