So I ran into this as well, took me a bit but I figured it out. I had to use which python to find out where python was installed, turns out I had installed it with homebrew, and pip was under the Frameworks dir
which pip /Library/Frameworks/Python.framework/Versions/3.12/bin/pip
So then I installed pip with homebrew as well and tried to install it again and got the following
pip install pandas error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try brew install xyz, where xyz is the package you are trying to install. If you wish to install a non-brew-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. If you wish to install a non-brew packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
So I then followed what it advised me to do and created a virtual environment in the directory my project was in.
python3 -m venv ./
After that I still couldn't get it, pip kept giving me the same error until I ran it like this:
./bin/pip install pandas
and THAT worked... so now I run
./bin/python3 filename.py
And I no longer get the error. It's all about finding where your python that you're actually using is, and using that to run your scripts.
I hope this helps someone out there!
export PATH="/usr/local/opt/python/libexec/bin:$PATH"source: discourse.brew.sh/t/…