Pandas not working in macOS (Monterey)

pandas although installed in mac os with site pacakages under library/framework/… /sitepackages and also installed Anaconda individual login and updated anaconda as well. But still pandas moudule not found. Even import sys and sys.path also verified. I am running latest Python 3.9.10 and also Anaconda Navigator 2.1.1. Tried troubleshooting from Stack Overflow and even Pandas own documentation as well

Screen. shots
xyz@xyz-MacBook-Pro:~% pip install pandas --upgrade
Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.4.0)
Requirement already satisfied: numpy>=1.18.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pandas) (1.22.2)
Requirement already satisfied: python-dateutil>=2.8.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pandas) (2021.3)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)
xyz@xyz-Pro:~%

What’s probably happening is the command you are using to run Python is not the same one that the pip command installs into. Try doing python3 -m pip install --upgrade pandas (and change python3 to whatever command you’re using to run Python). See Why you should use `python -m pip` for an explanation as to why using -m pip is almost always a better option.

Hello Brett
Thanks but result will be the same. Still same issue

Vasu Rao
DevOps Practitioner/Computer Systems Analyst
Specialist in current technologies

Best I can tell you is to use python -m pip list to see what pip sees. Otherwise if you’re using conda make sure the conda environment you installed into is activated.

Based on your output, it is clear that your pip command is installing pandas into either system Python or the Python installed by the python.org installer, which is very likely not what you want if you have Anaconda installed.

Instead, first active your anaconda environment with conda activate base (or conda active <env-name>), then install pandas with conda via conda install pandas. If you’ve installed Anaconda, not Miniconda, then pandas is already installed in the base env; simply typing conda activate base, then python, then import pandas should show you it is installed. However, it is usually a good idea to work in a clean non-base env, so you can easily modify, delete and recreate it as needed; conda create your-env-name-here will create a new environment named your-env-name-here which you can then activate with conda activate your-env-name-here and conda install pandas into.

Also, you should avoid installing packages with pip under an Anaconda env, especially heavy-duty ones like Pandas, if you can possibly avoid it, as it defeats most of the benefits of using Anaconda for hefty scientific packages and can cause serious conflicts with other packages you have installed.

For more appropriate further help, since this is the site for the Python language, not Anaconda, I suggest reaching out on a Anaconda-specific help forum. Best of luck!