Problem with default python3 and pip3 locations
I have run numerous python3 installations on a couple of MacBook Pros over the last 10 years, always installing from python.org so am familiar with where these installs usually reside.
Now I have a new Mac Mini M2 running Sonoma 14.2.1. I wanted to check out the default python3 environment before installing my own.
Not knowing anything about the default file locations, from my home directory I entered
% which python3
/usr/bin/python3
% which pip3
/usr/bin/pip3
and that seemed consistent, so I used pip3 to install Jupyter Lab
% pip3 install jupyterlab
Installation messages scrolled up and everything seemed OK. So, still within my home directory I entered
% jupyter lab
zsh: command not found: jupyter
OK, I guess I might need to edit my $PATH. So I went to check where pip3's packages are
% pip3 -V
pip 21.2.4 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework
/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
This was as little surprising as I thought (from 'which' above) that pip3 was located at /usr/bin/pip3
I checked /usr/bin/pip3 and it is not a symlink.
So I added /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages to the front of my $PATH in my .zshrc, sourced that and tried the jupyter lab command again. Same result, command not found.
I manually inspected the site-packages directory in the above path and none of the jupyter packages are there.
However, when I pip3 list, Jupyter is included along with all of its dependencies. None of these were in the site-packages directory I looked at.
Then I started up the python3 REPL from my home directory to find the location of the python3 binary
% python3
Python 3.9.6 (default, Nov 10 2023, 13:38:27)
[Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.executable)
/Library/Developer/CommandLineTools/usr/bin/python3
Again, surprising, as the 'which' command above returned /usr/bin/python3 — and just as with /usr/bin/pip3, not a symlink. To remove any doubts about PATH configuration I ran /usr/bin/python3 directly and got the same results as to the location of the executable.
% /usr/bin/python3
Python 3.9.6 (default, Nov 10 2023, 13:38:27)
[Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.executable)
/Library/Developer/CommandLineTools/usr/bin/python3
So I have 3 questions
- Why does ‘which’ show the /usr/bin locations but python3 and pip3 themselves report different locations?
- 'pip3 list' thinks jupyterlab is installed but the package is not located in pip3’s site-packages directory
- Where did pip3 actually install jupyterlab and its dependencies, and why there?
Mac mini (M2, 2023)