ModuleNotFoundError: No module named 'pdpbox'

As part of Lesson 4 of the ML course, I’m trying to import the pdpbox and plotnine packages into my Jupyter notebook on Crestle. However, I ended up with the following error:

ModuleNotFoundError: No module named 'pdpbox'

I have already pip-installed the pdpbox and plotnine packages into my Crestle machine. As for environments, I think Crestle only starts off with one environment to begin with. I’m a complete noob when it comes to CLI/bash commands so if someone can guide me through what needs to be done, that would be very helpful!

Can you check to see if the package is listed as being installed. What happens when you type in !conda list or !pip list into a notebook cell.

it’s possible you have different versions of python installed and you pip installed pdpbox for some different version.
An empirical set of steps I follow in such cases are :-

  • Make sure you have the right kernel selected on your jupyter notebook (mostly the conda env you created before starting out, its always suggested to create a separate new conda env)
  • Type in !pip list or !conda list (as stated above) if the package is actually installed or not in the path available for our current notebook, in your case it shall not be present here because you can not import it.
  • Make sure the sys.path on python has included the path to where your conda/pip packages are installed, if not, try to install the package in some of the included path or add a new path reference
  • Worst case, I simply make a new conda env and start from the beginning.

Hi @davidh
When I type in !pip list, I get the following packages amongst others:

PDPbox 0.2.0
plotnine 0.4.0

So it seems the packages are present in the notebook environment…

Hmm. A bit strange. Can you check what conda environments are listed when you type !conda info --envs into a cell and run.

This is what the cell spits out:

/bin/sh: 1: conda: not found

Ok, sounds like the system can’t find your conda installation. If you run !echo $PATH or !echo {$PATH}, can you type out what it says. Ideally there should be a link to Anaconda in there.

That outputs:
/usr/local/bin:~/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Aha, no link to Anaconda. So just to check. When you run start your jupyter notebook server with “jupyter notebook” command. Did you run something like “source activate fastai” or “source activate fastai-cpu” before.

No I didn’t, because I’ve been able to use the other modules within fastai in the Jupyter notebook. What does this command do exactly?

Typing in “source activate fastai” allows me to switch to using a different anaconda environment. Each environment can have different packages installed and I have one for fastai that I activate before running a jupyter notebook server.

If after trying that does not work, then maybe Anaconda is not installed correctly and so you might have to start again.

Hmm it’s odd that I can’t even run the command:

nbuser@jupyter:~$ source activate fastai
bash: activate: No such file or directory

Try conda activate fastai

Can’t run this command either:

nbuser@jupyter:~$ conda activate fastai
bash: conda: command not found

i tried first with installing pip install pdpbox: did not work. same error
ModuleNotFoundError: No module named 'pdpbox'
again i tried with pip3 install pdpbox : it worked. can you please try using pip3…

same with the plotnine as well

That worked! I used:

pip3 install pdpbox
pip3 install plotnine

Were you able to find out why pip3 worked but not pip?

do the following:

pip uninstall pdpbox
pip install pdpbox

note that you don’t have to close your current session for this, just open up a new anaconda prompt, and once it’s installed, do the import again, and it should work

I couldn’t find package with !pip list . So, I did following to resolve the issue. Hope following helps.

It seems like this is a Python path issue where your packages are being installed. Just try to install packages within your notebook with !pip install pdpbox and this worked for me.