I’m doing the “Demographic Data Analyzer” project, but I’ve been doing it on Visual Code because Replit doesn’t work. When I compile any code, even the default code from the exercise, it gives me:
Traceback (most recent call last):
File “main.py”, line 2, in
import demographic_data_analyzer
File “/home/runner/boilerplate-demographic-data-analyzer/demographic_data_analyzer.py”, line 1, in
import pandas as pd
ModuleNotFoundError: No module named ‘pandas’
The Pandas package is enabled on the website. I’ve tried to “pip install pandas” but it gives me:
File “”, line 1
pip install pandas
^^^^^^^
SyntaxError: invalid syntax
The code works perfectly on visual studio, so the problem is of replit.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Data Analysis with Python Projects - Demographic Data Analyzer
It appears to be the dependency problem of the python data analysis projects. The python interpreter is not finding pandas for whatever reason. The solutions in similar threads include:
Change the python version to 3.11 in pyproject.toml and remove and reinstall dependencies with the replit package tool.
You may have to execute the correct poetry commands directly in the replit shell.
You may have better luck with pip instead of poetry if poetry fails.
You may have to remove the poetry directory and poetry.lock to remove before reinstalling.
You may have to wait for slow times on replit as these are resource hungry commands.
The last straw is to copy/paste your code into a new, empty python project on replit. You should copy all files except poetry.lock as it will be regenerated.
This repl acted like one that has been slightly corrupted, so the replit package tool/poetry was not working but pip installed pandas so that the OP project would run.
By deleting poetry.lock (a generative file) and reinstalling poetry from packages folder will resolve this issue. Poetry will reinstall all the packages with latest versions.