在CentOs上搭建jupyter的远程访问环境

1、conda的安装

(1)conda的下载

# 使用以下命令下载conda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 注:若命令不存在,执行 yum install wget -y 安装即可

(2) conda的安装

bash Miniconda3-latest-Linux-x86_64.sh 
# 安装的过程中,一路yes或者回车即可

(3)添加环境变量

source /root/.bashrc

(4) 配置 aconda 仓库镜像源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

(5)python3.7.4环境的搭建

# 下载安装TensorFlow,OpenCV,jupyter
conda install -y tensorflow opencv jupyter

(6)查看安装模块的版本

conda list

2、配置jupyter服务器

(1)生成配置文件:

jupyter notebook --generate-config

(2)在python中运行以下代码获得加密的密码

from notebook.auth import passwd
passwd()

(3)打开配置文件:

vim /root/.jupyter/jupyter_notebook_config.py

(4)在配置文件中加入以下代码

# 设定ip访问,允许任意ip访问
c.NotebookApp.ip = '0.0.0.0'

# 不打开浏览器
c.NotebookApp.open_browser = False
	
# 用于访问的端口,设定一个不用的端口即可,这里设置为7000
c.NotebookApp.port = 7000
	
# 设置登录密码,xxx就是上面程序输出的加密了的密码
c.NotebookApp.password = u'xxx'
	
# 设置jupyter的工作路径
c.NotebookApp.notebook_dir = '/xxx/jupyter'

(5)在后台启动

nohup jupyter notebook --allow-root > notebook.log 2>&1 &
发布了5 篇原创文章 · 获赞 13 · 访问量 430

猜你喜欢

转载自blog.csdn.net/weixin_42690388/article/details/102846830
今日推荐