作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用环境变量作为 jupyter_notebook_config.py 中 c.NotebookApp.notebook_dir 参数的位置,但我已经添加了
c.NotebookApp.notebook_dir = $JUPYTER_NOTEBOOKS
我也创建了变量
>export JUPYTER_NOTEBOOKS=/home/jupyter
但是当我运行 Jupyter Notebook 时,我收到以下错误消息,我可以看出它没有提取变量的值,而是试图将变量用作文字。有没有人在 jupyter notebook 配置中成功使用环境变量?
[E 20:45:04.513 NotebookApp] Exception while loading config file /root/.jupyter/jupyter_notebook_config.py
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 562, in _load_config_files
config = loader.load_config()
File "/usr/local/lib/python3.6/site-packages/traitlets/config/loader.py", line 457, in load_config
self._read_file_as_dict()
File "/usr/local/lib/python3.6/site-packages/traitlets/config/loader.py", line 489, in _read_file_as_dict
py3compat.execfile(conf_filename, namespace)
File "/usr/local/lib/python3.6/site-packages/ipython_genutils/py3compat.py", line 198, in execfile
exec(compiler(f.read(), fname, 'exec'), glob, loc)
File "/root/.jupyter/jupyter_notebook_config.py", line 766
c.NotebookApp.notebook_dir = $JUPYTER_NOTEBOOKS
^
SyntaxError: unexpected character after line continuation character
[I 20:45:04.523 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "</usr/local/lib/python3.6/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1628, in initialize
self.init_webapp()
File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1407, in init_webapp
self.http_server.listen(port, self.ip)
File "/usr/local/lib/python3.6/site-packages/tornado/tcpserver.py", line 151, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python3.6/site-packages/tornado/netutil.py", line 174, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address
最佳答案
不清楚您是否正确使用了环境变量。我看了看文档,看起来 %env JUPYTER_NOTEBOOKS
是正确的方法。我在我的本地系统上检查过它并且它有效(对于不同的环境变量)。试一试 - 祝你好运! :-) 。以下是文档。
https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-env
关于jupyter-notebook - 在 jupyter_notebook_config.py 中使用环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55307758/
我刚开始使用 Mac,如果这听起来太幼稚,请原谅我。 我正在尝试安装 Interactive Parallel。来自 https://github.com/ipython/ipyparallel ,它
我想使用环境变量作为 jupyter_notebook_config.py 中 c.NotebookApp.notebook_dir 参数的位置,但我已经添加了 c.NotebookApp.noteb
我是一名优秀的程序员,十分优秀!