[英]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:案件:
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 forxdg-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 toelif 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.