2025, Nov 15 19:00
Fix PyCharm 'No module named pandas' with Poetry v2.1.3: point the IDE to the Poetry-created interpreter
Seeing 'No module named pandas' in PyCharm with Poetry? Set PyCharm's interpreter to the Poetry venv and mark src as a source root to quickly resolve imports.
When a project is managed with Poetry v2.1.3, the environment is created from pyproject.toml, and pandas is included as a dependency, it’s easy to assume everything is wired correctly once poetry update completes and the IDE shows the package as installed. Yet the script still fails with “No module named 'pandas'.” If you’re seeing this in PyCharm Community v2025.1.2, the issue isn’t with pandas at all—it’s with the interpreter PyCharm is using for this project.
Reproducible symptom
You have a valid configuration that declares pandas, Python >=3.12 and <4.0, and the environment is created successfully. But running a simple import in your project still raises a module-not-found error.
import pandas as pdata
print("Pandas version:", pdata.__version__)
Instead of printing the version, the script crashes with:
No module named 'pandas'
What’s actually going on
The environment built by Poetry and the interpreter configured in PyCharm are not the same. Even if the PyCharm UI lists pandas under the Project Interpreter, PyCharm may still be pointing at a different Python interpreter than the virtual environment that Poetry created for this project. As a result, your code runs against an interpreter where pandas isn’t installed.
How to fix it
First, locate the venv that Poetry created for the project. Use the command that prints the exact path to the environment. Then, in PyCharm, open Settings, go to Project → Python Interpreter, add an interpreter, choose an existing environment, and select the Python executable from that exact path (for example, the python inside the bin directory of the venv). If your code lives under src/poetry_demo/, make sure the src/ directory is marked as “Sources Root” so imports resolve correctly.
After pointing PyCharm to the Poetry venv, the same script runs successfully without any code changes:
import pandas as pdata
print("Pandas version:", pdata.__version__)
“Thank you, using your steps I was able to find the existing interpreter and point Pycharm to it. Now it works.”
Why this is worth knowing
Poetry owns dependency resolution and environment creation, while PyCharm owns the interpreter selection used to execute and index your code. If those two aren’t aligned, you get “installed but not found” contradictions and time-consuming debugging. Ensuring the IDE uses Poetry’s interpreter eliminates ambiguity, keeps imports consistent, and avoids brittle behavior across shells and tools.
Takeaways
When Poetry says a dependency is installed but your Python script can’t import it in PyCharm, verify that PyCharm is using the exact Poetry-created interpreter. Confirm the path with the Poetry command, switch the Project Interpreter to that path, and mark src/ as a Sources Root when your code lives under src/. Once the interpreter matches the venv that contains your packages, the import error disappears and the project behaves as expected.