I tried installing pandas but got the following error:
ModuleNotFoundError: No module named 'pandas'
That’s ok, it is a third party module.
Here’s what I did to try to fix it in IDLE:
import sys
print(sys.executable)
This is what I got:
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11
Right, so you’re on MacOS with Python 3.11.
I did this next:
pip -V
This is what I got:
NameError: name 'pip' is not defined. Did you mean: 'zip'?
This indicates to me that you’re typing this at Python’s >>>
interactive prompt, like this:
>>> pip -V
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pip' is not defined. Did you mean: 'zip'?
It is always helpful to copy/paste the entire command with its prompt
(here, the >>>
) and the full output. As text, not a screenshot.
pip
is a command and should be run at your shell prompt, not the
Python prompt. The usual incantation actually runs it using Python and
looks like this:
[~]fleet2*> python3 -m pip install pandas
Requirement already satisfied: pandas in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (2.1.4)
Requirement already satisfied: numpy<2,>=1.22.4 in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from pandas) (1.26.2)
Requirement already satisfied: python-dateutil>=2.8.2 in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from pandas) (2023.3.post1)
Requirement already satisfied: tzdata>=2022.1 in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from pandas) (2023.4)
Requirement already satisfied: six>=1.5 in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
[notice] A new release of pip is available: 24.0 -> 24.1
[notice] To update, run: pip install --upgrade pip
I’ve already got pandas
installed, so it mostly tells me I’ve already
done that. Your output should be more … fulfilling.
Here [~]fleet2*>
is my shell prompt and python3
should be whatever
command you used to start Python. This form ensures that pip
installs
to the same Python you’re using, as it is possible to have multiple
Python environments, and people sometimes install into one environment
and then use another, not realising the disconnect.