Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter reports "bad interpreter" following Homebrew Python update

Since updating my Python using Homebrew

jupyter --version

gives

-bash: /usr/local/bin/jupyter: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

which makes some sense, since there's no longer a Python at /usr/local/.../python2.7. But I don't see any way to repair this.

Prior to updating Python, I there was a Python there, and the Homebrew's symlinked python pointed there, but now which -a python gives

/usr/local/opt/python@2/libexec/bin/python
/usr/local/bin/python
/usr/bin/python

which corresponds to what I want, and are, respectively

  • Homebrew's 2.7, which is found because it is on PATH
  • Homebrew's symlinked 3.6.x
  • Apple's old Python

I've also brew link --overwrite --force python2 for good measure, but this has no effect.

How do I get jupyter to find and use the Python 2.7 on my PATH?

like image 886
orome Avatar asked Mar 04 '18 15:03

orome


2 Answers

Works for me, its just to link Jupiter with the correct Python version.

 rm '/usr/local/bin/jupyter'
 brew link --overwrite jupyter
 brew link --overwrite --dry-run jupyter
 brew unlink jupyter && brew link jupyter
like image 186
A. Juarez Avatar answered Sep 28 '22 03:09

A. Juarez


Homebrew moved the Python 2 to be keg-only, using the python@2 formula. The jupyter formula has been updated accordingly, please upgrade it:

brew update && brew upgrade jupyter

Note that the Python 2 binary is now only available as python2, the python binary, if installed by Homebrew, is Python 3.

If you installed it with pip, link the Python 2 binary and re-install jupyter using pip2:

brew link -f python@2
/usr/local/bin/pip2 install -U jupyter

You'll end up with a /usr/local/bin/jupyter file that starts with the line #!/usr/local/opt/python@2/bin/python2.7.

like image 30
Martijn Pieters Avatar answered Sep 28 '22 03:09

Martijn Pieters