Alexis Raymond
Alexis Raymond

Reputation: 53

Pandas not working even though its installed

I've installed python and pandas using the Anaconda library, but it doesn't work when I try to import pandas in Jupyter Notebook or in the Python Idle. It does work when I run the shell in the terminal.

I am using macOS Mojave and Python version 3.7.6.

In the terminal, it says I have pandas already installed as you can see below.

enter image description here

However, I get the error message "ModuleNotFoundError: No module named 'pandas'" when trying to import it in the Python Idle as you can see below.

enter image description here

I think I know where the problem comes from but I don't know how to troubleshoot or fix it. I installed Anaconda 2 years ago and used it but deleted it when I was done with it to make space in my computer and now I reinstalled it. So I think the Idle and Jupyter Notebook are using a different version of Python than the one that came in the Anaconda package. I might be completely wrong.

Thank you for your help!

Upvotes: 2

Views: 3857

Answers (3)

bhristov
bhristov

Reputation: 3187

If you want to use Anaconda, then just do:

conda install pandas

Mixing conda and pip may cause issues.

Upvotes: 1

mkostelac
mkostelac

Reputation: 301

You probably haven't installed pandas in the same environment your Jupyter kernel is running in.

You can install it directly from Jupyter notebook by running !pip install pandas. That will install it in the environment that the kernel started in.

In general, running !pip freeze from jupyter notebook should show you all installed libraries. If pandas is not there after you ran !pip install pandas, your environment paths are broken in some big way.

In that case, I'd suggest nuking anaconda and jupyter installation and starting again.

If you want to know more about kernels and how packages work in them https://biasandvariance.com/importing-packages-in-jupyter-notebook/ could help.

Upvotes: 2

Allen Qin
Allen Qin

Reputation: 19947

Can you try updating pandas?

pip install --upgrade pandas

Upvotes: 1

Related Questions