ModuleNotFoundError: No module named 'pandas'

Hello to the freeCodeCamp community!
In the following project: Data Analysis with Python Projects - Demographic Data Analyzer
I get the error ModuleNotFoundError: No module named ‘pandas’. So I “pip install pandas”, no more error on this, but minutes later, I once again get the same error, as if I had uninstalled pandas!!

HELP!! :pray:

Hi @Brice1. After googling the error message a bit, I came across this question on Stackoverflow which recommends running the following commands in succession. It appears to fix the error when I tried. You can try it as well. Hopefully it will work.

pip install wheel
pip install pandas

Hello there,

This does seem to be a issue. I believe’s workflow is:

  • Ensure the repl you are working with is given the correct language
  • import necessary modules/packages
  • Click RUN - will install the necessary packages, and create the .toml and .lock files.

If this goes on too long, it might be more convenient to download the scripts, and work locally, if that is an option.

2 Likes uses poetry as its package/environment manager for python and typically it just works when you run the project, but for some reason it didn’t when I just tried it. I didn’t see anything obviously wrong with your files and I ran poetry update (this is the poetry command to update/install required packages) in the console and it installed numpy and pandas. I was able to run your project at that point. I’m not sure why the poetry update part is not automatically running, but you can run it manually and everything works.

1 Like

Thanks everybody.

Now I have this each time I run the code: Updating package configuration

--> python3 -m poetry install
Installing dependencies from lock file

Package operations: 2 installs, 1 update, 0 removals

  - Updating numpy (1.19.1 -> 1.19.4)
  - Installing pytz (2020.4)
  - Installing pandas (1.1.4)

I have abandoned my quest to understand why. I have finished the project with that.

Just in case anybody is still struggling with this issue, I found out that the reason I was getting this error was because I had forgotten to fork the project, as the instructions said. Once I did it, it worked perfectly. So it might be something worth checking out.



Extremely useful comment! It worked. Thanks.

In most cases this error in Python generally raised:

  • You haven’t installed Pandas explicitly with pip install pandas.
  • You may have different Python versions on your computer and Pandas is not installed for the particular version you’re using.

You can run the following command in your Linux/MacOS/Windows terminal.

pip install pandas

To be sure you are not having multiple Python versions that are confusing, you should run following commands:

python3 -m pip install pandas
python3 -c 'import pandas'