gpt4 book ai didi

jupyter-notebook - 在 jupyter_notebook_config.py 中使用环境变量

转载 作者:行者123 更新时间:2023-12-04 15:47:00 30 4
gpt4 key购买 nike

我想使用环境变量作为 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com