简体   繁体   中英

jupyter notebook bad interpreter error message

I tried to use jupyter notebook with kernel python3, but I got this error message.

anonymous$ jupyter notebook
/usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

Information about python and pip installed on mac (i used pip3 to install jupyter ):

anonymous$ which -a python python2 python2.7 python3 python3.6
/usr/bin/python
/usr/bin/python2.7
/usr/local/bin/python3
/usr/local/bin/python3.6
anonymous$ which -a pip pip2 pip3
/usr/local/bin/pip
/usr/local/bin/pip3

Tried to solve it with "brew update && brew upgrade jupyter" as the other post suggested but did not work. Got an error message saying that "Error: jupyter not installed".

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.

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

pip3 install jupyter
jupyter notebook

I faced the same error when I was using jupyter in a virtual environment. This was when I switched from homebrew 's python to the OS's python3.

All I had to do was rm /usr/local/bin/jupyter-lab and then run jupyter-lab

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 faced the same and I tried $brew install jupyter as suggested here. But it gave me this error -

Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.

As M1 Mac user this solved the issue finally -

arch -arm64 brew install jupyter

As of October 2020, @teresa 's solution worked for me.

I have to run pip3 to install devices, you can check which command for pip you need to use by running

pip -v 

and if you get nothing, try pip3 -v

Depending one which one worked, enter:

pip3 install jupyter
jupyter notebook

It looks like "pip3" installs jupyter with the same Python version in the kernel and the one being used in the notebook.

pip3 install jupyter
jupyter notebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM