Taco Steemers

A personal blog.
☼ / ☾

Python bad interpreter: No such file or directory

Fix /usr/local/opt/python/bin/python3.7: bad interpreter: No such file or directory

The problem

Pelican, and other python-based applications, stopped working with the following error message:

$ pelican             
 bash: /usr/local/bin/pelican: /usr/local/opt/python/bin/python3.7: 
 bad interpreter: No such file or directory
  • Application: Pelican, or any other application built with Python3
  • Platform: macOS Catalina
  • Package manager: brew

It seems a brew command has broken the python applications. When I check if I have indeed used brew to install python, with brew list , I find that it lists python@3.8 . Pelican expects python@3.7, as we can see from the error message.

The solution

Update brew, and wait until the command has finished:

$ brew update

Then install the Python environment manager:

$ brew install pyenv

Using pyenv we can now select the python version for our shell. For the project that I am now trying to get working again I will add the correct command to the file that I use to start the application. pyenv shell 3.7.8 We will also need to install that version: pyenv install 3.7.8

Background

I think that brew updated the python version, but did not update the dependencies. This type of probleem seems to happen regularly with brew. Perhaps it does not correctly update all packages when a dependency has either been moved, or removed entirely.