ModuleNotFoundError: No module named 'pdpbox'


(Aditi Basu) #1

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!


(David Henderson) #2

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.


(vaibhav kumar) #3

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.

(Aditi Basu) #4

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…


(David Henderson) #5

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


(Aditi Basu) #6

This is what the cell spits out:

/bin/sh: 1: conda: not found

(David Henderson) #7

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.


(Aditi Basu) #8

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


(David Henderson) #9

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.


(Aditi Basu) #10

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?


(David Henderson) #11

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.


(Aditi Basu) #12

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

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

(Kevin Bird) #13

Try conda activate fastai


(Aditi Basu) #14

Can’t run this command either:

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

(narendra sahu) #15

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


(Aditi Basu) #16

That worked! I used:

pip3 install pdpbox
pip3 install plotnine

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


#17

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