记录一下anaconda的安装步骤。建议看官网,一下个人实验仅限参考,我个人按以下操作是成功的。官方文档上非常详细。
- 官方文档地址:
https://enterprise-docs.anaconda.com/en/latest/install/reqs.html - 下载地址
https://www.anaconda.com/distribution/
我的服务器
centos 7
步骤
一 下载安装包:
# 去下载地址找到对应版本的安装包 https://www.anaconda.com/distribution/
# 新建一个下载文件夹(非必要步骤)
mkdir /home/temp_pack && cd /home/temp_pack
# 我使用wget命令直接下载, 没有安装wget命令的自己搜索如何安装
wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
# 我这是linux python 3.7版本的
二 安装
bash Anaconda3-2019.10-Linux-x86_64.sh
# 安装过程,一路回车就行,大概就是让你看完协议,然后确认安装
三 确认安装
# 能显示出版本就安装好了
conda --version
四 Linux服务器配置juypter, 然后远程使用jupyter
# 安装完上面步骤,将自动进入一个虚拟环境
# 进入python 交互环境,生成密钥
python
# 然后照以下步骤生成密钥
from notebook.auth import passwd
passwd()
# 输入方便你记的密码,连续输;两次..输完密码后,会输出一个字符串,形如: ’sha1:xxx’
# 将其保存下来。
六 配置jupyter notebook
# 默认安装路径 /root/anaconda3/etc/jupyter
# 进入到安装目:
cd /root/anaconda3/etc/jupyter
# 执行以下命令, 会产生配置文件 root/.jupyter/jupyter_notebook_config.py
jupyter notebook --generate-config
七 编辑配置文件
# 编辑配置文件
vim root/.jupyter/jupyter_notebook_config.py
# 随便找一行添加以下配置文件
c.NotebookApp.ip = '*' #允许访问此服务器的 IP,星号表示任意 IP
c.NotebookApp.password = u'sha1:xxxxxxxx:xxxxxxxxxxxxxxx' # 之前生成的密码 hash 字串
c.NotebookApp.open_browser = False # 运行时不打开本机浏览器
c.NotebookApp.port = 7788 # 端口随意设置,注意确保云服务器此端口要开放。
c.NotebookApp.enable_mathjax = True # 启用 MathJax
c.NotebookApp.allow_root = True
c.NotebookApp.notebook_dir = '/root/JupyterNotebook' #工作目录,保存代码项目文件。
# :wq 保存退出
# 两个注意事项
mkdir /root/JupyterNotebook # 工作目录需要自己创建
# 云服务商的服务器端口,需要自己去控制面板打开
八 运行jupyter notebook启动远程环境
# 命令行输入以下命令开启,
jupyter notebook
# ctrl+C 退出
# 验证是否正常
浏览器输入ip http://xxx:7788/ 看看是否能访问
九 后台运行
# 上面步骤 命令直接输入 jupyter notebook 关掉中断就直接关掉了
# 所以需要在后台运行
# 有很多后台运行方式, 最简单如下,就能在后台运行了
nohup jupyter notebook &
较好的后台运行是可以用
supervisro
管理你的进程
简单的后台运行方式还有 setsid + 启动命令
这里就是 setsid jupyter notebook
- 后台运行方式, nohub setsid的参考
https://www.jianshu.com/p/8958a20ce23d
https://blog.youkuaiyun.com/overstack/article/details/8626520