Seeing ModuleNotFoundError: No module named 'pandas' on a Mac is a common Python setup problem, not a sign that pandas is broken or that your code is wrong. The error means the Python interpreter currently running your script, notebook, or terminal session cannot find the pandas package. That's why on macOS, this usually happens because pandas was installed into a different Python installation, a different virtual environment, or a different Jupyter kernel. The fix is to identify the interpreter that is actually running your code and install pandas into that exact environment.
You'll probably want to bookmark this section That's the part that actually makes a difference..
Why the Mac ModuleNotFoundError: No module named 'pandas' Error Happens
macOS often has more than one Python installation. Each one has its own package library. You may have Apple’s developer tools Python, a Homebrew Python, a python.org installer, Anaconda, Miniconda, pyenv, or a virtual environment created for a specific project. Installing pandas with one pip command does not automatically make it available to every Python interpreter on the machine.
The error typically appears in one of these situations:
- You ran
pip install pandas, but your code runs withpython3from a different installation. - You installed pandas globally, but your project uses a virtual environment that does not have pandas.
- You activated a Conda environment, then installed pandas with a system
pipoutside that environment. - You installed pandas in a terminal, but Jupyter Notebook or JupyterLab is using a different kernel.
- Your IDE, such as VS Code or PyCharm, is configured to use an interpreter that does not contain pandas.
- You are using an Apple Silicon Mac and mixed terminals or Python builds running under different architectures.
The key idea is simple: pandas must be installed in the same Python environment that executes your code But it adds up..
Quick Diagnosis: Which Python Is Running?
Before installing anything, check which interpreter your code is using. In Terminal, run:
python3 -c "import sys; print(sys.executable)"
This prints the full path to the active Python interpreter. Next, check which pip belongs to that interpreter:
python3 -m pip --version
The safest installation command is almost always:
python3 -m pip install pandas
Using python3 -m pip forces pip