Running pip or pip3 results with:

Traceback (most recent call last):
File "/home/myuser/.local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named 'pip._internal'

I had issues with this, and uninstalled pip3, but when i try to install it again using

sudo apt-get -y install python3-pip

it does install, but then running pip or pip3 i get the same error.

#which pip3
  • 2
    I have a similar problem after upgrading from pip 9.0.2 to pip-10.0.0. Ubuntu 16.04LTS here.
    – Dave
    Apr 15, 2018 at 11:19
  • 3
    You should not upgrade to pip 10 on Ubuntu, because the system version installed through apt is modified in a way not compatible to pip 10. See github.com/pypa/pip/issues/5221 @Dave
    – Byte Commander
    Apr 15, 2018 at 12:27
  • macOS 10.13.4, same problem after upfgrade to pip 10
    – Benjamin R
    Apr 21, 2018 at 4:38
  • 3
    Temporary workaround: python3 -m pip install --user <package>
    – Benjamin R
    Apr 21, 2018 at 22:14
  • 1
    if you have easy_install (comes from python-setuptools package), you can do sudo easy_install pip (or sudo easy_install3 pip for python3-only, etc.) May 25, 2018 at 14:40

8 Answers 8


After upgrading pip (or pip3, in this case) if the following occurs:

$ ~ pip3 -V
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'

Force a reinstall of pip:

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

Verify install:

$ ~ pip3 -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Now pip3 install <package> and pip3 install --user <package> (for user-level installs) will work correctly.

There should never, ever be any reason you need to run pip in elevated mode.

For Python 2.7

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

Had same problem on macOS as well, it's a common issue across platforms.

  • 2
    Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/bin/pip3'
    – endolith
    Aug 21, 2018 at 10:44
  • 1
    @endolith Okay, now you want to use sudo rm -rf /usr/bin/pip3 – purge that existing directory first, then install from scratch. It's a permissions problem on that directory, but it's better to reset in these circumstances I believe, you can always easily reinstall whatever packages you lose again. If that doesn't work, nuke your Python 3 install, too, then reboot.
    – Benjamin R
    Aug 23, 2018 at 8:57
  • 1
    @endolith Hi, it depends on what your OS (and distro, if Linux) is. Let me know and I’ll try to point you in the right direction. p.s. We’ve all been in your position more times than most of us like to admit :)
    – Benjamin R
    Aug 24, 2018 at 14:35
  • 1
    @endolith Okay! See: fosslinux.com/3534/…
    – Benjamin R
    Aug 25, 2018 at 11:57
  • 1
    @endolith Once you've done that, run which python / which python3. If nothing turns up, reboot your machine, then reinstall python 2/3 using apt-get install <package name>. Finally, if you run in to something unexpected, run find / -iname python* (you'll probably need sudo permissions for these commands). If anything turns up which is a directory with a binary, remove the enclosing directory, then reboot.
    – Benjamin R
    Aug 25, 2018 at 12:03

I solved this by updating pip via Python, like this:

python2 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade pip
  • 4
    /home/{user}/bldenv/bin/python3: No module named pip Jun 22, 2021 at 18:29
  • yeah this worked for me while the the curl-based answer above did not. Jul 5, 2021 at 6:38

This command also works. It reinstalls pip:

sudo easy_install pip
  • 4
    That's the easiest answer! Aug 8, 2018 at 17:16
  • 4
    Worked like a wonder on Ubuntu Sep 9, 2018 at 0:53
  • 5
    I got sudo: easy_install: command not found Mar 23, 2021 at 8:38
  • WARNING: The easy_install command is deprecated and will be removed in a future version.
    – Darwin
    Dec 31, 2021 at 19:07
  • Traceback (most recent call last): File "/usr/local/bin/easy_install", line 5, in <module> from setuptools.command.easy_install import main ImportError: cannot import name 'main' from 'setuptools.command.easy_install' (/usr/lib/python3/dist-packages/setuptools/command/easy_install.py)
    – Snowcrash
    Jan 20, 2022 at 11:37

Apply these three steps:

  1. Go to /usr/local/bin by terminal
  2. Execute sudo gedit pip
  3. Change the from pip._internal import main into from pip import main.

Check if pip is already installed using

pip3 -V 


pip3 --version

If not use this command to install it:

sudo apt install python3-pip

Now you can use

python3 -m pip install packageName

to install packages using pip.

  • 1
    this is what OP is already dong.
    – Nik O'Lai
    Aug 23, 2019 at 11:57

I got the same problem as you just now, I found the reason is that you are working without superuser privilege since some internal python packages or modules are installed under superuser privilege.

So you can try by fist entering sudo su, then enter your password, and run pip install, it might help.

  • 4
    You should never, ever need to run pip with elevated permissions. Use --user flag instead, as in: pip3 install --user <package>
    – Benjamin R
    Apr 21, 2018 at 4:44
  • 1
    However, when I run without superuser permission, I still got the information like pip3 install --user Traceback (most recent call last): File "/usr/local/bin/pip3", line 7, in <module>\\ from pip._internal import main ImportError: No module named 'pip._internal' Could you please help me to figure out why this always happen?
    – Daniel
    Apr 22, 2018 at 5:21
  • 2
    Ok, I found out why, if from pip._internal import main error happen, in my solution, 1) curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 2) python3 get-pip.py --user --force-reinstall, and then you can run pip without superuser permission, Thank you very much for your advice, it helps a lot !
    – Daniel
    Apr 22, 2018 at 5:36
  • My pleasure! Look, I learned the hard way to be careful about using sudo willy-nilly (destroyed my OS multiple times!)
    – Benjamin R
    Apr 23, 2018 at 7:34
  • Hmmm askubuntu.com/a/802594/5032
    – endolith
    Aug 21, 2018 at 10:40

A force re-install of pip with -H flag worked for me:

sudo -H python3.7 get-pip.py --force-reinstall

The pip version now is 19.0.1:

which pip3
vim /home/xxx/.local/bin/pip3

Change from pip._internal import main into from pip import main

  • 1
    Traceback (most recent call last): File "/usr/local/bin/pip3", line 5, in <module> from pip import main ImportError: cannot import name 'main' from 'pip' (/usr/lib/python3/dist-packages/pip/__init__.py)
    – fccoelho
    Jan 10, 2020 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .