jupyter notebook bad interpreter error message

This problem usually occurs when the kernel for jupyter notebooks is being loaded from a previous python version that might not exist anymore.

  • Run jupyter kernelspec list. kernel.json contains the path to the python version in use. You can either change this path directly, or nuke the Jupyter install (as follows) and reinstall it.
  • Remove the Jupyter folder location (on mac: rm -rf /Users/<username>/Library/Jupyter/)
  • brew uninstall jupyter; brew cleanup
  • If using pip and pyenv: pip install jupyterlab otherwise brew install jupyter

I reinstalled jupyter notebook with pip3 and everything worked fine when I treid to lauch the notebook again.

pip3 install jupyter
jupyter notebook

You must have installed jupyter with another package manager such as pip. You can try pip uninstall jupyter followed by brew install jupyter.

If you get the message:

Error: The `brew link` step did not complete successfully 
The formula built, but is not symlinked into /usr/local 
Could not symlink bin/jupyter 
Target /usr/local/bin/jupyter already exists.

You can try brew link --overwrite jupyter as suggested.