On April 30, 2018, https://xkcd.com/1987/ got published. This wasn't the first time that Randall Munroe posted about Python (probably the most famous comic was his import antigravity one which became an actual module in the stdlib as an easter egg), but it was the first comic that people construed as negative towards Python.

The interesting thing is Randall never blamed Python for the situation he found his laptop in. If you read the alt text on this post you will notice he said:

The Python environmental protection agency wants to seal it in a cement chamber, with pictoral messages to future civilizations warning them about the danger of using sudo to install random Python packages.

So he admits that he did bad things. But people took the confusing nature of the comic as proof/justification to come out and either be upset at Python overall, be upset about deploying Python, or some other thing to be upset over. And when I suggested maybe we look at our install process, people replied with xkcd.com/927/ which wasn't helpful.

So this obviously touched a nerve. In this post I will break down the comic in an attempt to try an de-mystify what has happened to Randall's laptop. Some of it is Randall's own doing, some of it is Apple's doing, some of it is Homebrew (although you could argue Homebrew's point of existence is Apple's fault), and some of it is Python's. Hopefully by the end you will agree with me that no single person is at fault with this and that software is hard. 😁

The Comic

To make it easier to reference, here is the original comic (which is licensed under Creative Commons Attribution-NonCommercial 2.5 License):


The interpreters


Apple includes Python 2.7.10 out-of-the-box as the system Python for their own use. Unfortunately this interpreter is rather old and is linked against a very old version of OpenSSL. It's honestly best to avoid and to treat as a private tool/app for macOS' own needs (and which is generally good advice for any OS that happens to include Python by default).


Some people might be wondering why the "Anaconda Python" node of the graph has no specified Python version. Well, that's because conda, the environment manager for Anaconda, lets you specify the Python you want to use. So if you download miniconda which just gives you conda, you can then construct environments as necessary without having to manage your Python installation manually. In other words, if you like conda you can stop here in terms of Python installations.


Although most developers like macOS for its UNIX base, Apple never shipped a UNIX-level package manager, hence Homebrew came into being. And because Python is used very often as part of or to develop code running on UNIX systems, Randall had Homebrew install Python 3.6. Now I don't know if Randall installed this explicitly or if it got pulled in as part of a dependency in Homebrew, but it could affect whether he could have the Python install that came with miniconda be on his PATH.


Everything that applied above to the Python 3 install by Homebrew applies to Python 2 from Homebrew.


For the macOS install from python.org I really can't comment on without knowing why Randall had such an old version of Python installed. Maybe he was running some really old code? Perhaps his Mac is so old this was a reasonable version of Python to install early on? I also can't comment as to why he installed to begin with or why he never uninstalled it.

The tools


Having pip installed is not a shocker. The real question is what interpreter pip is attached to? That's dependent on which Python interpreter was installed last in the earliest directory to have a Python interpreter in it. This is why you should always use python -m pip when executing pip to guarantee you are using pip with the interpreter you intend to install for.


This ties into the comment I made above about not knowing which interpreter the pip command is attached to. The fact that there's more than one most likely stems to Python interpreters being installed into multiple bin directories with their accompanying pip command.


easy_install is included in macOS's creaky old version of Python. Homebrew will also install it for Python 2.7. But that's not coming from the python.org installer and honestly shouldn't be used in today's pip world.

The paths


  • /usr/local/Cellar is from Homebrew
  • /usr/local/opt is probably old Homebrew (or at least I remember Homebrew installing there back in the day)
  • **/Frameworks/ is macOS' Python install
  • ~/python/ is probably from Randall himself
  • ~/newenv/ is also from Randall himself
  • /usr/local/lib/python3.6/ is Homebrew
  • /usr/local/lib/python2.7/ is also Homebrew


This either represents the system install of Python or Randall's sudo-install of Python that he references in the alt text of the comic.


Not even sure what this is supposed to even mean. 😄


Whatever PATH is set to is between Randall and his shell. 😉 Obviously it should be set to notice Python installed, so most likely contains /usr/bin and /usr/local/bin to get the system install and all the other installs of Python that he has.


Whatever PYTHONPATH is set to will be system-specific to Randall and not because of some installation of Python.


To me, the point of this xkcd comic is for Randall to be self-deprecating and point out how he let the Python situation on his computer get out of hand. Unfortunately people don't always pick up on this and instead decide to point at this picture and say, "see, Python is messed up!" But if you take the time to really look at the comic you will notice that pretty much none if it is directly Python's own fault (not knowing what pip is pointing at is pretty much the only thing you could point at and say is still the Python community's fault).

当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
若有不妥, 欢迎评注提醒:



关于 ~ DebugUself with DAMA ;-)

关注公众号, 持续获得相关各种嗯哼:

公安备案号: 44049002000656 ...::