当前位置: 首页 > article >正文

Ubuntu服务器安装JupyterNotebook,以便通过浏览器访问Jupyter

1.安装Anaconda/Miniconda

在Ubuntu中安装Miniconda

2.创建环境

conda create -n jupyter_env python=3.12

3.安装

conda install jupyter notebook

pip install -U jupyter

4.配置,生成访问密码

# 1.进入python环境
python

# 2.生成sha1密码
from jupyter_server.auth import passwd

passwd(algorithm='sha1')

# 3.重复输入两次密码,复制保存sha1密码

5.生成配置文件

jupyter notebook --generate-config

6.编辑生成的配置文件

vim /home/<conda_user>/.jupyter/jupyter_notebook_config.py
# 在该文件最后一行加入以下内容

# 设置访问IP
c.NotebookApp.ip = '0.0.0.0'
# 输入刚刚生成的sha1密钥
c.NotebookApp.password = 'sha1:*****************************'
# 默认不自动打开浏览器
c.NotebookApp.open_browser = False
# 设置端口, 其他端口也是可以的
c.NotebookApp.port = 8888
# 设置Jupyternotebook 打开的根目录,可自行创建设置文件目录 (mkdir jupyter_notebook_workspace)
c.NotebookApp.notebook_dir = '/home/<conda_user>/jupyter_notebook_workspace'
#是否允许远程访问   
c.NotebookApp.allow_remote_access = True

 参考链接:

ubuntu搭建jupyter_notebook服务器

Ubuntu 20.04 安装 Jupyter notebook (宝宝级攻略)

jupyter安装与使用——Ubuntu服务器

jupyter notebook远程控制ubuntu服务器(使用篇)

7.启动

jupyter notebook

# 后台运行请查看使用 nohup 相关命令

8.输入IP+端口号可在本地浏览器访问

# ip地址:端口号
ip:port

9.开放防火墙端口(如果在浏览器不能访问jupyter的情况下)

# 0.查看防火墙状态,是否是running
firewall-cmd --state

# 1.查看开放端口(–zone #作用域)
firewall-cmd --zone=public --list-ports

# 2.添加端口
firewall-cmd --zone=public --add-port=<端口号>/tcp --permanent

firewall-cmd --zone=public --add-port=8888/tcp --permanent

# 3.重新加载配置
firewall-cmd --reload

# 4.查看开放端口
firewall-cmd --zone=public --list-ports

# 不需要时可关闭端口号
firewall-cmd --zone=public --remove-port=<端口号>/tcp --permanent

参考链接:Linux防火墙管理:systemctl与firewall-cmd命令详解

10.使env在jupyter中显示并可用

# 激活环境
conda activate jupyter_env

# 安装必要插件
conda install ipykernel

# 使该环境在jupyter notebook 环境选项中显示
python -m ipykernel install --user --name jupyter_env

# 删除选项
jupyter kernelspec uninstall jupyter_env

参考链接:[Erron 13] Permission denied:’/usr/local/share/jupyter’_erron<13>-CSDN博客


http://www.kler.cn/a/588620.html

相关文章:

  • 【数据分析】索引与数据筛选(1)
  • 【Prometheus】k8s集群内部署的prometheus如何监控kubernetes集群
  • centos steam8 部署k8s
  • JavaScript性能优化实战指南
  • 腾讯云CloudStudio使用笔记(三)
  • 如何减少跨团队交付摩擦?——基于 DevOps 与敏捷的最佳实践
  • 如何用AI制作PPT,轻松生成高效演示文稿
  • 软件架构设计、详细设计和开发编码的过程中提高性能的技巧和方法
  • REDIS生产环境配置
  • Git使用和原理(3)
  • Git的基本指令
  • C# WPF 基础知识学习(三)
  • Leetcode-1278.Palindrome Partitioning III [C++][Java]
  • 使用 Flask 进行简单服务器改造的详细步骤和代码
  • 在 React 中使用 Web Components 的实践操作
  • Blender-MCP服务源码1-项目解读
  • Linux find 命令完全指南
  • 接口测试中常见的bug有哪些?
  • 使用elementplus的table表格遇到的问题
  • ubuntu ollama+dify实践