9.4 C
New York
Saturday, January 13, 2024

Repair "ModuleNotFoundError: No module named 'pip'" in Python


As a Python developer, you might have encountered the error ModuleNotFoundError: No module named 'pip'. This error is often thrown whenever you try to make use of pip, Python’s package deal installer, however it’s not obtainable in your system. It is a frequent subject, particularly for novices establishing their Python setting for the primary time or when switching between completely different Python variations. On this Byte, we’ll discover this error intimately, perceive why it happens, and learn to repair it.

The Error

The error ModuleNotFoundError: No module named 'pip' is considerably self-explanatory, however why it occurs could be complicated. It implies that Python is unable to find the pip module in your system. To know why this error happens, let’s think about a state of affairs.

For example you have simply arrange Python in your Mac. You run python setup.py set up to put in the required packages to your challenge. All the things appears to be going easily. Then, you attempt to set up a brand new package deal utilizing pip with pip set up. All of a sudden, you are confronted with the error message: ModuleNotFoundError: No module named 'pip'.

$ python setup.py set up
# ...
$ pip set up
ModuleNotFoundError: No module named 'pip'

So what went unsuitable? Effectively, the error means that pip, which is meant to be part of your Python set up, is lacking. This could possibly be as a result of quite a lot of causes, like having a defective Python set up, a misconfigured setting, or the usage of an outdated Python model.

Notice: It is necessary to know that pip will not be a built-in Python module. It is a package deal supervisor that comes bundled with the newest Python installations. If it is lacking, it does not imply there’s one thing unsuitable with Python itself. It simply implies that Python cannot discover it.

The best way to Repair the Error

Resolving this error could be achieved in a number of methods, relying in your Python model and working system. In our case, to illustrate we’re coping with a macOS setting, so we’ll begin there.

For those who’re utilizing Python 3.4 or later, Python features a script to bootstrap the pip installer, which you’ll set off with the next:

$ python3 -m ensurepip

This invokes the Python interpreter to run the ensurepip module, which is a bootstrapping script that makes an attempt to put in pip into your setting.

As soon as you have run this, strive working pip set up once more. If it really works with out throwing the ModuleNotFoundError, congratulations, you have fastened the problem! If not, don’t be concerned, there are different strategies to strive.

Notice: For those who’re utilizing an older model of Python, you may not have the ensurepip module obtainable. On this case, you will must improve your Python model or search different strategies to put in pip.

For Ubuntu customers, there’s another choice. You should use the package deal supervisor apt to put in pip. This is the command to take action:

$ sudo apt set up python3-pip

This installs the pip package deal for Python 3 through the apt package deal supervisor. As soon as the set up is completed, you need to be capable to use pip with out encountering the error once more.

One other different is to only use a model of Python that comes with pip put in. Python variations 2.7.9 and three.4 and later variations include pip pre-installed. For those who’re utilizing an older model of Python, think about upgrading to a more moderen model. Upgrading could also be easier should you preserve getting this error and it is best to be on the newest model of Python anyway.


On this Byte, we explored the ModuleNotFoundError: No module named 'pip' error, its frequent causes, and tips on how to repair it on a Mac or Ubuntu system, particularly.

Supply hyperlink

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles