ModuleNotFoundError: No module named pandas error

In my jupyter notebook my first statement is

import pandas as pd

I already used pip3 to install pandas. I don’t think there is anything wrong in terms of syntax. I have tried looking at stack overflow articles to see if there is a way to fix it.

I have tried the conda install command and the !pip freeze commands.
I have run the pip3 install pandas command as well. In all instances it says the requirement is already satisfied.

Any advice?

Wait, did you use both conda and pip3 to install Pandas? Because that could be your issue. Conda doesn’t know what pip installed (and vice versa). I would stick to one or the other but not both conda and pip.

Did you install pandas in the same location (dir) that you installed Python?
How did you initiate Jupyter Notebook in Terminal? It could be that there’s a location issue between where you installed Pandas and where you’re working in Python.

I used the conda install command AFTER I ran pip3 install Jupyter. When I ran pip3 it didn’t work.

I initiate jupyter notebook with the jupyter notebook command in my visual studio code terminal.

“did I install pandas in the same directory as I installed python?”

I have run that command many times. I am certain I have already run the conda install command in the same folder as my project.

indeed pip list confirms this.

where is jupyter installed?

When you installed pandas, did you do: pip3 install pandas ?

Check to see if the directories are the same. In terminal:

pip3 --version
>> the path will be here:

python3 --version
>>the path will be here. Are they the same?

In the terminal, when you do a:

python3
>>import pandas as pd

what happens? any errors?

I would install jupyter using pip3 instead of conda. I’m thinking they’re installed in different places on your Mac.

outputs:

pip3 --version
Python 3.11.4

python3 --version
outputs: Python 3.11.4

python3

import pandas as pd

output

it seems nothing happens when i do the import command from the terminal in visual studio code…
unless it just imported it?

If nothing happens, then it’s installed correctly.

As I am understanding it…you used conda to install jupyter?

What happens with:

which -a jupyter
>>Is it the same as the other dirs where python is installed?

You can initiate Jupyter in your terminal window, which will open a window in your web browser. You don’t have to use visual studio.

Maybe this will help?

Spoke with another codecademy user and he said launching from the conda software and accessing the information that way should have it see pandas and everything installed. → This is true. pandas works when I do this.

For conda you can set up environments like so: Managing environments — conda 23.7.3.dev33 documentation
For pip see e.g. Installing packages using pip and virtual environments — Python Packaging User Guide

For pip you can learn about environments with this link: Installing packages using pip and virtual environments — Python Packaging User Guide

Okay, so then what’s the issue?

Or, you could always just use Colab and bypass all of this.

he just told me to use the conda software which seems to have solved my problem temporarily.

I probably need to set up virtual enviornments going forward.

Whats this about Colab?

Was it @tgrtim? :slight_smile: He’s very resourceful and I usually look to him for answers. (he’s actually helped many people with installation issues here over the years.)

Look up Google Colab. It’s an app you add to your Drive. It’s based on Jupyter and looks like it but it’s cloud-based. But, everybody is different, so use what you know/like.

yeah he is the truth.

thank you for your help lisalisaj

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.