简体   繁体   English

每次我运行“jupyter notebook”时,为什么我总是在 mac os 上得到这个?

[英]Everytime i run “jupyter notebook”, why I always got this on mac os?

Everytime i ran "jupyter notebook" on my mac os, why always got this error?每次我在 mac os 上运行“jupyter notebook”时,为什么总是出现这个错误?

case:案件:

  1. i have python2.x and i installed python3.7 (so, i have two commands here)我有 python2.x 并且我安装了 python3.7(所以,我在这里有两个命令)
  2. i installed jupyter with pip我用 pip 安装了 jupyter
  3. when i put jupyter notebook command, i always got these error当我输入 jupyter notebook 命令时,我总是收到这些错误

Error:错误:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/jupyter-notebook", line 11, in <module>
  sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
  return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
  app.start()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/notebook/notebookapp.py", line 1697, in start
  browser = webbrowser.get(self.browser or None)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/webbrowser.py", line 42, in get
  register_standard_browsers()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/webbrowser.py", line 531, in register_standard_browsers
  raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 376, in check_output
  **kwargs).stdout
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 453, in run
  with Popen(*popenargs, **kwargs) as process:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
  restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, in _execute_child
  raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: 'xdg-settings'

I got the same NotADirectoryError: [Errno 20] .我得到了同样的NotADirectoryError: [Errno 20] In your case, the file it is pointing to is 'xdg-settings' .在您的情况下,它指向的文件是'xdg-settings'

It seems that the file 'xdg-settings' might be a shortcut and the actual file can't be found.似乎文件'xdg-settings'可能是一个快捷方式,无法找到实际文件。 What you can do is simply delete that file (ONLY if it is a shortcut) .您可以做的只是删除该文件(仅当它是快捷方式时) Then restart jupyter notebook and it should work fine.然后重新启动 jupyter notebook,它应该可以正常工作。

For anyone finding this error, here's how you solve it ( credit to @rrios-eq on Github ):对于发现此错误的任何人,以下是解决方法( 归功于 Github 上的 @rrios-eq ):

It's a if/else logic bug in webbrowser.py ;这是webbrowser.py的 if/else 逻辑错误; a simple fix is to edit /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/webbrowser.py (or wherever Jupyter is pointing you to) and then look for xdg-settings in the code.一个简单的解决方法是编辑/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/webbrowser.py (或 Jupyter 指向您的任何地方),然后查看对于代码中的xdg-settings

Several lines above (15 in my case), you will have if sys.platform[:3] == "win": if you change it to elif sys.platform[:3] == "win": then the Darwin/Windows/Linux will work properly.上面几行(在我的例子中是 15 行),你将有 if sys.platform[:3] == "win":如果你把它elif sys.platform[:3] == "win":那么 Darwin/ Windows/Linux 将正常工作。 I'm running python3.7 from Homebrew using macOS 10.14.2.我正在使用 macOS 10.14.2 从 Homebrew 运行 python3.7。

From warp-x : If you don't mind opening your browser manually, you can pass --no-browser when starting the notebook: $ jupyter notebook --no-browser .来自warp-x :如果您不介意手动打开浏览器,可以在启动笔记本时传递--no-browser$ jupyter notebook --no-browser You can then open your browser, navigate to the notebook in a browser (normally localhost:8888 ) manually and do you your work.然后,您可以打开浏览器,在浏览器(通常为localhost:8888 )中手动导航到笔记本并完成您的工作。

找到文件/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/webbrowser.py然后是函数register_standard_browsers然后查找if sys.platform[:3] == "win":并通过elif sys.platform[:3] == "win":更改它并保存文件,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每次运行 jupyter 笔记本时,我是否必须重新启动 kernel? - do i have to restart the kernel everytime I run a jupyter notebook? 我可以打开 jupyter 笔记本,但无法在 Mac 上运行带有 python 脚本的笔记本 - I can open a jupyter notebook, but I cannot run the notebook with python script in it on my Mac jupyter notebook 无法在 Mac 上运行 - jupyter notebook cannot run on Mac 如何从 Mac 终端访问 Jupyter Notebook [将 Mac OS 从 High Sierra 更新到 Catalina 后] - How to do I access Jupyter Notebook from Terminal of Mac [ After updating the Mac OS from High Sierra to Catalina ] 在 Jupyter 笔记本中插入图像时出现错误 - I got errors when i inset the image in Jupyter notebook 我可以运行 Jupyter Notebook 而不是 Databricks 吗? - Can I run Jupyter Notebook instead of Databricks? "我可以在命令行中运行 Jupyter 笔记本单元格吗?" - Can I run Jupyter notebook cells in commandline? 如何在 Mac 上为 Jupyter Notebook(Anaconda) 创建桌面快捷方式? - How can I create a desktop shortcut for Jupyter Notebook(Anaconda) on Mac? 无法直接在 Mac 上的终端中运行 Jupyter notebook - Cannot run Jupyter notebook directly in the terminal on Mac Pycharm每次设置单元运行时便启动新的Jupyter笔记本 - Pycharm starting a new Jupyter notebook everytime a cell is set to run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM