欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 幼教 > Anaconda下安装配置Jupyter

Anaconda下安装配置Jupyter

2025/5/16 14:23:09 来源:https://blog.csdn.net/qq_39065491/article/details/140612099  浏览:    关键词:Anaconda下安装配置Jupyter

Anaconda下安装配置Jupyter

1、安装

conda activate my_env	#激活虚拟环境
pip install jupyter	#安装
jupyter notebook --generate-config	#生成配置文件

提示配置文件的位置:


Writing default config to: /root/.jupyter/jupyter_notebook_config.py

检查版本:

# jupyter --version
Selected Jupyter core packages...
IPython          : 8.12.3
ipykernel        : 6.29.5
ipywidgets       : 8.1.3
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.2
jupyterlab       : 4.2.4
nbclient         : 0.10.0
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : 7.2.1
qtconsole        : 5.5.2
traitlets        : 5.14.3

2、配置

(1)修改配置参数

打开jupyter 的配置文件 ,修改以下配置内容:

c.ServerApp.notebook_dir = ‘/root/jupytercode’# 配置程序代码路径
c.ServerApp.port = 8686	#配置可用端口
c.ServerApp.open_browser = False	#禁止自动打开浏览器
c.ServerApp.allow_remote_access = True	#允许远程访问
c.ServerApp.allow_root = True #允许root用户
c.ServerApp.ip = '*' # 允许所有IP访问

注意:配置参数前面一定不能有空格

开始没有注意,服务总是不能启动,看日志中:

File "/root/anaconda3/envs/nlp/lib/python3.8/site-packages/traitlets/config/loader.py", line 655, in _read_file_as_dictexec(compile(f.read(), conf_filename, "exec"), namespace, namespace)  # noqa: S102File "/root/.jupyter/jupyter_notebook_config.py", line 653c.ServerApp.allow_remote_access = True^IndentationError: unexpected indent
(2)防火墙端口

把防火墙上的8686端口打开

firewall-cmd --list-port
firewall-cmd --zone=public --add-port=8686/tcp --permanent
firewall-cmd --reload
(3)本机测试

用 wget 测试网址

# wget 192.168.88.128:8686
--2024-07-23 00:48:24--  http://192.168.88.128:8686/
正在连接 192.168.88.128:8686... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:/tree? [跟随至新的 URL]
--2024-07-23 00:48:24--  http://192.168.88.128:8686/tree?
再次使用存在的到 192.168.88.128:8686 的连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:/login?next=%2Ftree%3F [跟随至新的 URL]
--2024-07-23 00:48:24--  http://192.168.88.128:8686/login?next=%2Ftree%3F
再次使用存在的到 192.168.88.128:8686 的连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:6254 (6.1K) [text/html]
正在保存至: “index.html”100%[===========================================================================================================>] 6,254       --.-K/s 用时 0s2024-07-23 00:48:24 (194 MB/s) - 已保存 “index.html” [6254/6254])

说明可以访问。

(4)设置密码

在浏览器中访问:
在这里插入图片描述
按提示执行命令 jupyter server list:

# jupyter server list
Currently running servers:
http://localhost:8686/?token=53c428fd7e7cfb9b440e29bf73c8ec12a9602d53243ad49e :: /root/jupytercode

把token后的密码串,复制到token的文本框中,然后输入密码。
网站设置成功!

(5)后台启动

设置到后台启动:

nohup  jupyter notebook  > /root/.jupyter/jupyter.log 2>&1 &

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词