My other related Q&A, since it’s important to have a full understanding:
Thanks for pointing out that I’m missing something for the externally-managed-environment message And I guess I should write something about Terminal vs Python commands generally, but I’m not sure if it’s on topic over there. I’ll talk with the community.
I got this from print(sys.executable): /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11. Is this the right path or should I look for something else, like /usr/local/bin/python3?
You should be making venvs in your home directory. For example:
python3 -m pip $HOME/venv
You’re installing into /Library, which is owned by the operating system vendor (Apple), not you, the user. I’m rather surprised that the above command even worked.
Keeping user-installed stuff (like pandas, at least pandas installed by a user using pip) out of the area managed by the operating system vendor is a primary reason that pip no longer tries to install into the “system” presupplied Python.
Operating systems have a QA processes during their release to ensure that things work correctly. This inherently tests the release against the Python and the library modules installed with it, and not against whatever versions some user might install later. We try to leave the vendor managed area alone, so as not to introduce different, possibly only subtly different, packages into it which can change how the core OS works.
What that command will do is install pandas into the Python associated
with whichever pip3 command you ran. The command which pip3 will
tell you which one you are using.
If you sourced the activate script from a venv then that should be the pip3 from the venv, and therefore it should install to the venv.
Just keep this association in mind - it affects where packages get
installed. That’s also why we usually recommend:
python3 -m pip install ...whatever...
You still need to know where python3 is coming from, but at least it’s
slightly more direct.