macOS升级到12.5后jupyter不能自动打开浏览器

升级了macOS后一直也没有使用jupyter notebook,昨天使用了发现竟然不能自动打开浏览器了。

终端下调用jupyter notebook

➜  LearnPythonNotebook git:(master) ✗ jupyter notebook
zsh: /usr/local/bin/jupyter: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
[I 13:58:51.602 NotebookApp] Serving notebooks from local directory: /Users/smslit/Desktop/LearnPythonNotebook
[I 13:58:51.602 NotebookApp] 0 active kernels
[I 13:58:51.602 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=f6ca93231d4791de0dd64749e7f2fd62a50e55fc01456716
[I 13:58:51.602 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:58:51.606 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=f6ca93231d4791de0dd64749e7f2fd62a50e55fc01456716
0:97: execution error: “"http://localhost:8888/tree?token=50b06d86ad89e16f44b101656e1b3aec168231dd00b143a4"”不理解“open location”信息。 (-1708)

问了一下我们的哥(谷歌),找到了解决方案,在~/.jupyter目录下创建文件jupyter_notebook_config.py,文件内容如下:

c.NotebookApp.browser = u'Safari'
c.NotebookApp.token = ''
c.NotebookApp.password = ''

重新启动一下jupyter notebook:

➜  LearnPythonNotebook git:(master) ✗ jupyter notebook
zsh: /usr/local/bin/jupyter: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
[W 14:19:57.878 NotebookApp] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
[I 14:19:57.888 NotebookApp] Serving notebooks from local directory: /Users/smslit/Desktop/LearnPythonNotebook
[I 14:19:57.888 NotebookApp] 0 active kernels
[I 14:19:57.888 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 14:19:57.888 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

可以自动打开safari了,peace!