Import pandas is working in Terminal, but not running in Jupyter Notebook (on Mac)

Hello, everyone!

I’m doing Data Science Career Path and having an issue related (as I consider) to a conflict between two versions of Python installed on my Mac.
https://www.codecademy.com/paths/data-analyst/tracks/dsf-python-fundamentals-for-data-science-part-i/modules/dsf-getting-started-off-platform/articles/getting-started-with-jupyter

The problem is that the command “import pandas as pd” is running in the Terminal successfully, but in Jupyter Notebook it returns an error: “ModuleNotFoundError: No module named ‘pandas’”.

Have anyone had this issue? Thanks in advance for your help! :pray:t4:

It means that pandas is installed in different path than Jupyter notebook.

Where did you install Pandas?

Also—does it work in Colab?

See:
https://stackoverflow.com/questions/54497098/import-pandas-as-pd-importerror-no-module-named-pandas

And:
https://stackoverflow.com/questions/35253338/import-pandas-on-jupyter-ipython-notebook-fails#35253514

1 Like

I can’t recall if you had used pip to install things.

Did you try:
!pip install pandas in the notebook itself?

Did you see this? (midway down the page):

But, as I mentioned above, Pandas is installed/lives in a different place than where Jupyter was installed. They need to be in the same place.

1 Like

Hello, lisalisaj!

After !pip install pandas in the notebook itself I get these messages:

Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.4.2)
Requirement already satisfied: numpy>=1.18.5 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from pandas) (1.22.4)
Requirement already satisfied: python-dateutil>=2.8.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from pandas) (2022.1)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.8/lib/python/site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)

When you installed pandas, did you do a conda install pandas where python 3.8 lives??

Where did you install Jupyter and did you use conda or pip to install it?
ie:
conda install -c conda-forge jupyterlab
or,
pip3 install jupyter

1 Like

lisalisaj, it works!!! :blush:
Great thanks for fast responces! :heart_eyes:

1 Like