ModuleNotFoundError: No module named 'pandas'

Hi! I realize there are several topics with this issue, but I’ve applied the fixes in them and it still doesn’t seem to have solved my problem. I’m experiencing this issue with the Sea Level Predictor exercise in the Data Analysis with Python course.

Error message:

python main.py
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import sea_level_predictor
  File "/home/runner/boilerplate-sea-level-predictor/sea_level_predictor.py", line 1, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
exit status 1

I have:

  • Updated pyproject.toml Python version to 3.8.
  • Updated poetry.lock pandas Python version to “>= 3.8”.
  • Added/verified that pandas, numpy, etc are included my replit.nix file.

When attempting to run the replit project, I also see this error flashed up for a brief moment:

Replit: Updating package configuration

--> python3 -m poetry add matplotlib
Using version ^3.6.0 for matplotlib

  ParseVersionError

  Unable to parse ">=1.17.4".

  at venv/lib/python3.8/site-packages/poetry/core/semver/version.py:211 in parse
      207│         except TypeError:
      208│             match = None
      209│ 
      210│         if match is None:
    → 211│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      212│ 
      213│         text = text.rstrip(".")
      214│ 
      215│         major = int(match.group(1))

I’m not sure if these are related or not, but any assistance would be fantastic. Thanks in advance!

Could you link to your replit?

No problem.

Link

It’s the same issue as the others (the first error), but somehow your poetry.lock was not parsing (the second error). After forking, I deleted poetry.lock, set python = ">=3.8,<3.12" (for scipy), uninstalled and reinstalled pandas, scipy, and matplotlib, and all worked.

That solved it, thanks!

Hi, I am trying to understand your solution and apply to my code. Any chance you can explain it with more detail?

  1. You deleted poetry.lock, meaning right click, delete from the project and get rid of it?
  2. What do you mean by this set python = ">=3.8,<3.12" (for scipy)?

Thanks is advance!!

Yes, delete the file. Whichever way you choose.

The OP was talking about their pyproject.toml. This is a setting in there.

1 Like

I tried and it worked. Well I got another error but it has something do with my code I guess, I just need to look into a bit more. Anyway thank you so much! Cheers!

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