Solving Python module not found even though “Requirement Already satisfied in Pip” ( after running pip install )

Python module not found even though “Requirement Already satisfied in Pip” ( after running pip install ) is a popular error which occurs sometimes when you try to install a package using the pip package manager.

In today’s blog post I am going to present an annoying and confusing python error and explain why this error is taking place and how to fix it, with a set of possible fixes.

Exploring the Error : Python module not found even though “Requirement Already satisfied in Pip” ( after running pip install )

This is a popular error which occurs sometimes when you try to install a package using the pip package manager.

Please make sure the error message looks like the error message bellow after double checking. Do not mix between errors.

                                                                       #
Requirement already satisfied: 
ImportError: no module named package-name
                                                                       #

Bellow is a number of tested solutions that I have tried and that have worked for me.

Solution 1 : Correctly use pip install –target=/usr/local/python3.9/site-packages –upgrade package-name

The best method in my opinion is this one, which is exactly why I started with it.

The treick is to first making sure you are running the command as the root user to get rid of any user related issues.

The second thing, which is the most important thing here is to specify the absolute path to the package inside the site-packages folder.

You can do that by using –target=/usr/local/python3.7/site-packages –upgrade

For example if you want to install Matplotlib, you should use the command bellow

                                                                       #
sudo pip install --target=/usr/local/python3.9/site-packages --upgrade matplotlib
                                                                       #

In general this is how the command should look like

                                                                       #
sudo pip install --target=/usr/local/python3.9/site-packages --upgrade package-name
                                                                       #

You should replace package name with the name of the package.

If that did not work, please make sure to install with pip3 instead of installing with pip

                                                                       #
sudo pip3 install --target=/usr/local/python3.9/site-packages --upgrade package-name
                                                                       #

And replace python3.9 with the version of python you have already installed ( for example python3.8 if you have python 3.8 )

Solution 2 : use python3 -m pip install or (python -m pip install)

If you have many different versions of python installed, the best way to install a package is by using python3 -m pip or python -m pip

To choose between pip3 or pip, we can use python3 -m pip or python -m pip :

We use python3 -m pip to choose pip3 for the install

We use python -m pip to choose pip for the install

This is how to put this into practice when installing a package ( Do not forget sudo )

                                                                       #
sudo python -m pip install package-name

# and to select pip3 use :
sudo python3 -m pip install package-name
                                                                       #

I hope this guide solved your problem, thank you for reading this entire blog post.

Summing-up : 

This is the end of our article, I hope the solutions I presented worked for you, Learning Python is a fun journey, do not let the errors discourage you. Keep coding and cheers.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/