# A package is installed in pip, but I can’t find it when I import it in python. What should I do?

It struck me for 1 hour the first time I met this problem.

Here is the way to fix it

Usually, as a user without administrator rights, using Pip to install packages on the server needs to be installed under their own Home.

Sometimes the package cannot be found after the installation, and the import does not come in, and an error of no module named xxx will be reported. why? Because although it is installed under a path, Python cannot find this path. At this time, you need to change the environment variable.

Take matplot as an example

1) Confirm whether the package and the corresponding version are installed

$pip list | grep matplot 2) If it has been installed, then see where it is installed ceiec@tf:~$ pip install matplotlib

Requirement already satisfied: pyparsing in ./anaconda2/lib/python2.7/site-packages

3) Add the path to the PYTHONPATH environment variable

For example, add in the last line of ~/.bashrc

export PYTHONPATH=\$PYTHONPATH:"/home/ceiec/anaconda2/lib/python2.7/site-packages”

If there are multiple paths, they need to be separated by colons.

Scroll to Top