美文网首页
centos 安装 jupyter notebook

centos 安装 jupyter notebook

作者: 微笑城ios | 来源:发表于2023-01-04 11:07 被阅读0次

centos 安装 Jupyter notebook

安装 Anaconda3

1.首先清华镜像站 下载anaconda3

image.png
mkdir anaconda3
cd anaconda3
wget  https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-5.3.0-Linux-x86_64.sh

2. 下载好创建目录执行

# 安装 bzip2
yum install -y bzip2

# 执行命令  --- 特别注意 -u 不能弄掉了 
bash Anaconda3-5.3.0-Linux-x86_64.sh -u

3. 执行完毕之后

## 更新一下 bash  
source ~/.bashrc

4.安装插件

conda install jupyter

配置一下 jupyter

2、生成配置文件
jupyter notebook --generate-config

3、生成密钥
进入python环境:

from notebook.auth import passwd 
passwd() 
此时会让你两次输入密码(该密码作为客户端登录jupyter用),然后就会生成秘钥 (秘钥作为配置文件用) 
************


4、编辑配置文件
vim ~/.jupyter/jupyter_notebook_config.py

# 注意将 # 注销掉才会生效
c.NotebookApp.ip='*'                                   # 就是设置所有ip皆可访问 也可以设置 0.0.0.0  
c.NotebookApp.password ='sha:ce...'       # 刚才复制的那个密文'  
c.NotebookApp.open_browser = False       # 禁止自动打开浏览器  
c.NotebookApp.port =8888                         # 随便指定一个端口  
# 配置默认目录 可以先创建一个 文件, 方便用户管理
c.NotebookApp.notebook_dir = '/home/xxx'        


5、在服务器端启动 jupyter notebook  
jupyter notebook --allow-root

6、然后远程地址栏输入服务器ip:8888 就可访问了,输入密码,就可以成功登录了

6. 设置后台运行

# 后台启动jupyter命令,nohup防止ssh断开,而服务停止。& 后台运行
nohup jupyter notebook --allow-root  &          

7. 添加中文字体 SimHei

# 查看安装的位置 
pip show matplotlib

# 对应路径下配置
1. matplotlib 配置中文, 下载免费的中文字体 SimHei
2. 将simhei.ttf放入/usr/local/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/ttf

3、修改/usr/local/lib/python3.8/site-packages/matplotlib/mpl-data/matplotlibrc

  在#font.sans-serif : 下添加  simhei,并去除注释

  如:

  font.sans-serif : simhei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

  font.family : sans-serif

  axes.unicode_minus : False

4、重启jupyter内核。

相关文章

网友评论

      本文标题:centos 安装 jupyter notebook

      本文链接:https://www.haomeiwen.com/subject/kjflcdtx.html