一、Anaconda3安装
-
从清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn//anaconda/archive/ 中找到(.sh)文件下载连接,我所安装的版本是:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
-
使用wget 下载以上anaconda3安装包
[root@VM-0-7-centos home]# wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
- 使用bash命令安装Anaconda3-5.3.1-Linux-x86_64.sh
[root@VM-0-7-centos home]# bash Anaconda3-5.3.1-Linux-x86_64.sh
安装过程中按Enter建继续,当出现是否安装VsCode
询问时,输入no
即可;
- 配置Anaconda环境变量
先执行一下命令:
[root@VM-0-7-centos home]# vim /root/.bashrc
并在vim打开的配置文件最后加入anaconda的安装路径:
export PATH="/root/anaconda3/bin:$PATH"
然后按Esc,输入 :wq(表示保存并退出)
使用一下命令重现加载配置文件
[root@VM-0-7-centos home]# source ~/.bashrc
最后测试是否成功:
[root@VM-0-7-centos home]# conda -V
conda 4.5.11
若看到conda 版本,说明anaconda安装成功!
二、配置jupyter notebook 远程环境
- 生成配置文件
[root@VM-0-7-centos home]# jupyter notebook --generate-config
生成的配置文件路径为:/root/.jupyter/jupyter_notebook_config.py
- 创建访问密码
[root@VM-0-7-centos ~]# jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json
- 创建hash密码
[root@VM-0-7-centos ~]# ipython
Python 3.7.0 (default, Jun 28 2018, 13:15:42)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:3454fd2b8ca1:2e9cf3f77dc9a169dfdd83ccdad167cb99fc7f3b'
In [3]: quit
[root@VM-0-7-centos ~]#
- 配置jupyter_notebook_config.py文件
vim 打开jupyter_notebook_config.py
配置文件:
[root@VM-0-7-centos ~]# vim /root/.jupyter/jupyter_notebook_config.py
并在打开的文件中更改一下几个选项(vim 先按esc
然后:/c.NotebookApp.password
查找):
c.NotebookApp.password = u'sha1:3454fd2b8ca1:2e9cf3f77dc9a169dfdd83ccdad167cb99fc7f3b'
c.NotebookApp.port = 8889
c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
- 后台激动jupyter服务:
[root@VM-0-7-centos ~]# nohup jupyter notebook --allow-root &
[1] 28966
后台运行jupyter服务后 ,本地浏览器输入IP地址和配置的端口号,并输入jupyter访问密码
即可登录操作
- 查找jupyter 后台进程
[root@VM-0-7-centos ~]# ps -aux | grep jupyter
root 28966 0.2 2.7 601440 56640 pts/0 Sl 16:07 0:01 /root/anaconda3/bin/python /root/anaconda3/bin/jupyter-notebook --allow-root
- 释放进程
[root@VM-0-7-centos ~]# kill -9 28966