r/programminghorror • u/[deleted] • Jan 12 '22
Python environment
https://imgs.xkcd.com/comics/python_environment.png[removed] — view removed post
1.4k
Upvotes
r/programminghorror • u/[deleted] • Jan 12 '22
[removed] — view removed post
78
u/JackMacWindowsLinux Jan 12 '22
In particular, Python on macOS is just very messy overall. The default python binary points to 2.7, which is shipped with macOS. You can install newer versions of 2 and 3 from Python.org, but to avoid conflicts with the system, these are installed in
/Library/Frameworks/Python.framework. Apparently both 2 and 3 are installed here, but the binaries in 3 are suffixed with3to avoid conflicts with the system version. Furthermore, you can install Python 2 (deprecated) or 3 through Homebrew, which sticks it in/usr/local/Cellar/python@x/x.y.z(referenced in the comic), and the files are symlinked to/usr/local/opt/python@xas well as the appropriate places in/usr/local. So if you installed all of these at some point, you'll have multiple ways to run Pythons of various versions:/usr/bin/python=> system 2.7/Library/Frameworks/Python.framework/bin/python[3]=> Python.org 2.7/3.x/usr/local/bin/python=/usr/local/opt/python@2/bin/python=/usr/local/Cellar/python@2/2.7.18/bin/python=> Homebrew 2.7/usr/local/bin/python3=/usr/local/opt/python@3/bin/python3=/usr/local/Cellar/python@3/3.y.z/bin/python3=> Homebrew 3.xI don't have experience with Anaconda, but if it ships its own Python too then that's another way to run it.
In the end, Python on macOS really is a mess, and it would be nice if Apple could ship Python 3 as default, but that would break things that rely on the system version being 2.7, and, well, Apple.