Modules Are Installed Using Pip on Osx But Not Found When Importing

Modules are installed using pip on OSX but not found when importing

Since your problem maybe caused due to various reason, I have listed down a few of them here :

  • This is possibly because of what ever is stated here : Pip installs but module is not found. Have updated the answer with newer link.

The link you were looking for : https://pythonhosted.org/setuptools/setuptools.html#development-mode

  • It may also happen if you have two versions of python installed. If the pip that you are accessing is of one version & the python interpreter used is another.

So just see to that you are using the same version of python to install and use the package.

You may fix this using alias,

First, set up a shell alias:

alias python=/usr/local/bin/python3

Then, type that at a prompt, or put it in your ~/.bashrc so that whenever you open python from the terminal the correct version opens.

  • If both of the above methods don't work for you then check this :

ImportError No module named or this

Python pip install module is not found. How to link python to pip location?

As a quick workaround, and assuming that you are on a bash-like terminal (Linux/OSX), you can try to export the PYTHONPATH environment variable:

export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages"

For Python 2.7

Unable to import a module that is definitely installed

In my case, it is permission problem. The package was somehow installed with root rw permission only, other user just cannot rw to it!

Can't install some pythons modules and some python modules are showing incompatible in my macbook

I was able to fix the problem on my MacBook pro m1 by deleting all pip packages using

pip3 freeze | xargs pip3 uninstall -y

then reinstalling the required module. In my case matplotlib using

pip install matplotlib


Related Topics



Leave a reply



Submit