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_dict
        exec(compile(f.read(), conf_filename, "exec"), namespace, namespace)  # noqa: S102
      File "/root/.jupyter/jupyter_notebook_config.py", line 653
        c.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 用时 0s

2024-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 &

相关推荐

  1. 在Ubuntu上安装Anaconda配置远程访问Jupyter

    2024-07-22 19:48:06       22 阅读
  2. Windows 安装 jupyter notebook

    2024-07-22 19:48:06       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 19:48:06       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 19:48:06       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 19:48:06       45 阅读
  4. Python语言-面向对象

    2024-07-22 19:48:06       55 阅读

热门阅读

  1. SAP 如何修改统驭科目类型

    2024-07-22 19:48:06       15 阅读
  2. 部署Mojo模型:生产环境中的智能自动化

    2024-07-22 19:48:06       15 阅读
  3. Linux的shell的date命令

    2024-07-22 19:48:06       15 阅读
  4. Haproxy

    Haproxy

    2024-07-22 19:48:06      15 阅读
  5. 免费云服务器

    2024-07-22 19:48:06       18 阅读
  6. 智慧文元宇宙

    2024-07-22 19:48:06       14 阅读
  7. Redis和mysql如何保持数据一致?

    2024-07-22 19:48:06       12 阅读