PIP3 ModuleNotFoundError: No module named 'pip._internal.cli.main' on Mac OS

Question:

I get stuck on a thing today and i don’t find how to resolve it.
I already check most of common answer for this problem on stackoverflow and other platforms but can’t manage to unblock the situation.

I’m on MacOs Big Sure with python3.7 and pip3

Let me explain, everything started today while wanting to install new package with pip.

    (base) thomas@Thomas ~ % pip3 install stripe

Traceback (most recent call last):
  File "/Users/thomas/anaconda3/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'

So basically i tried the solution :

python3 -m pip install --upgrade pip --user

Which let me know :

Installing collected packages: pip
  WARNING: The scripts pip, pip3, pip3.10 and pip3.7 are installed in '/Users/thomas/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.3

From there i update my path on ./basch_profile with this :

alias pip='pip3'
alias python='python3'
export PATH="$PATH:~/Library/Python/3.7/bin"
export PATH="$PATH:/Users/thomas/.local/bin"

Restart session , nothing change

I also added the path to ~/.bashrc, once again nothing change

I updated anaconda with

sudo env "PATH=$PATH" conda update conda

I also tried to force reinstall pip with :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

leading to the same result as the path should be change

I’m a bit out of solution even if i suppose i’m really close to it .

Thank’s everyone

Asked By: L.S

||

Answers:

I ended by uninstalling anaconda.

In fact anaconda was causing many troubles on his own.

After uninstalling anaconda, i used to reinstall pip with

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

Adding to my bash_profile and

/Library/Frameworks/Python.framework/Versions/3.7/bin

finally :

source .bash_profile

et voilĂ  !

Answered By: L.S
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.