Pip not working after downgrading

I downgraded pip to install some packages. but now pip is not working saying. my python version is 3.11.5 and used this command “sudo python -m pip install pip==18.0 --upgrade”

Error code:
Traceback (most recent call last):
File “/home/hasitha/.local/bin/pip”, line 5, in
from pip._internal import main
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_internal/init.py”, line 42, in
from pip._internal import cmdoptions
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_internal/cmdoptions.py”, line 16, in
from pip._internal.index import (
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_internal/index.py”, line 14, in
from pip._vendor import html5lib, requests, six
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/init.py”, line 25, in
from .html5parser import HTMLParser, parse, parseFragment
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/html5parser.py”, line 8, in
from . import _tokenizer
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/_tokenizer.py”, line 16, in
from ._trie import Trie
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/init.py”, line 3, in
from .py import Trie as PyTrie
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/py.py”, line 6, in
from ._base import Trie as ABCTrie
File “/home/hasitha/.local/lib/python3.10/site-packages/pip/_vendor/html5lib/_trie/_base.py”, line 3, in
from collections import Mapping
ImportError: cannot import name ‘Mapping’ from ‘collections’ (/usr/lib/python3.10/collections/init.py)

Welcome to the forum :slight_smile:

A few points:

  1. Please, never use sudo python -m pip unless you’re absolutely sure of what you’re doing. It’s a quick way to seriously wreck your environment, possibly beyond repair if you overwrite system packages.
  2. Code and error messages are best shared as text rather than screenshots, so that anyone can read them. I had to squint pretty hard to make out what that image says :slight_smile:
  3. You aren’t using Python 3.11 there; you’re using the system Python 3.10 (/usr/bin/python3.10). You appear to have a virtual environment (base) activated, but the pip you called came from your Python 3.10 user site-packages (/home/hasitha/.local/bin/pip).
  4. As you found, pip==18.0 is not compatible with a Python that new. According to the classifiers at on the PyPI page for pip 18.0, the newest version it supported was Python 3.6. Fortunately, since it does appear to be installed to your user site-packages, you should be able to clean things up by removing /home/hasitha/.local/lib/python3.10/site-packages/pip*, and the system-wide pip installation should still work.
  5. I’m not sure how downgrading pip would help you install a package :slight_smile: . What was the original issue you were facing; perhaps we can help with that?
1 Like

Big thank you .I updated the error message with code. It fixed my pip error. I am very sorry about uploading image. Firstly, I was trying to running a model in a virtual machine. For that ‘ctcdecode’ module installation failed. I am not pretty sure but I thought of downgrading pip version may work. That is the cause for the error.

What trouble did you have with installing ctcdecoder? I’m not at all familiar with it, but I found each of ctcdecode, pyctcdecode, and ctcdecoder on PyPI. The latter appears to be a broken and possibly abandoned package (or malware, hard to tell :slight_smile: ), the former requires PyTorch to be pre-installed (which is its own can of worms), and the middle installed quickly and easily in a Python 3.11 venv. If you share the error you had with that installation, we can try to help.

1 Like

Sure, Thank you in advance. I have pytorch preinstalled and It gives a loong error message. I’ll attach it. When i typed “pip install ctcdecode” it gives me error message lastly saying,

/home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
27 | #error You need C++17 to compile PyTorch
| ^~~~~
third_party/kenlm/util/integer_to_string.cc:47:10: fatal error: util/integer_to_string.hh: No such file or directory
47 | #include “util/integer_to_string.hh”
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:4,
from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
Preformatted text from /home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/all.h:9,from/home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,from ctcdecode/src/binding.cpp:5:
/home/hasitha/miniconda3/lib/python3.11/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
4 | #error C++17 or later compatible compiler is required to use ATen.
| ^~~~~
ctcdecode/src/binding.cpp:7:10: fatal error: scorer.h: No such file or directory
7 | #include “scorer.h”
| ^~~~~~~~~~
compilation terminated.
error: command ‘/usr/bin/gcc’ failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ctcdecode
Running setup.py clean for ctcdecode
Failed to build ctcdecode
ERROR: Could not build wheels for ctcdecode, which is required to install pyproject.toml-based projects

Ah now I saw the error may be issue with g++ version I think.

1 Like