4
votes

I've searched through other questions but have not found anything that has helped (most just suggest you do install pandas with conda or pip). In my jupyter notebook I'm trying to import pandas (import pandas as pd) but I'm getting the following error:

ModuleNotFoundError: No module named 'pandas'

Some pertinent information:

  • I'm using python3
  • I've installed pandas using conda install pandas
  • My conda environment has pandas installed correctly. After activating the environment, I type python into the terminal and from there I can successfully import pandas and use it appropriately. This leads me to believe that it is an issue with my jupyter notebook.
4
You probably need to set your notebook to use the correct kernel, the one associate with the conda env that has pandas installed... - juanpa.arrivillaga
@juanpa.arrivillaga it's set to the python3 kernel. I tried switching to the python2 kernel just to see what would happen and got a "kernel error" which I think is correct since this is a python3 environment. - CGul
do you only see two options for kernels? - juanpa.arrivillaga
yes - python2 and python3. - CGul
Did you use conda to install jupyter? - Shihe Zhang

4 Answers

4
votes

You can try: which conda and which python to see the exact location where conda and python was installed and which was launched.

And try using the absolute path of conda to launch jupyter.

For example, /opt/conda/bin/jupyter notebook

1
votes

Try this for python3

sudo pip3 install pandas

0
votes

For me on Mac OSX, this was solved by installing jupyter using pip, rather than homebrew

pip3 install jupyter

Then the jupyter notebook has access to all python packages, including pandas.

Another option would be to install pandas inside of the jupyter notebook:

!pip install pandas
0
votes

Its seems using homebrew installs for packages dependancies of home brew formulas are not handled by home brew well. Mostly path issues as installs are in different locations vs pip3, I also had tried installing pandas thru nb with !pip3, but I got errors that is was already satisfied meaning it was already installed just not importing. I uninstalled homebrew jupyterlab and used pip3 instead and all worked proper as a work around.