1. 下载安装
- 查看
# 查看CentOS是32还是64位版本
cat /etc/redhat-release
- 登录
ssh@xx.xx.xx.xx
- 下载 anaconda
# 记得从 [anaconda 官网](https://www.anaconda.com/download/#linux) 查看最新的版本
wget https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh `
- 安装 anaconda
# cd到对应下载目录, 安装anaconda的同时会安装自带的jupyter
sh Anaconda3-5.1.0-Linux-x86_64.sh
# 此后依照提示操作即可(最简便的方式就是,让ENTER就ENTER,问yes或no,输入yes,三个yes分别代表同意lisences, 一般默认安装在 /root/anaconda3
# 设置环境变量
sudo vi ~/.bash_profile
# bash_profile最后最后添加:
PATH="/root/anaconda3/bin:$PATH"
source ~/.bash_profile
#此时 python, conda命令行就可以用啦
2. 创建环境
- conda环境
参考: conda常用命令
conda create --name py36 python=3.6
conda activate py36
conda deactivate
# 删除环境:
conda remove --name py36 --all
# 列出环境:
conda info -e
- jupyter环境
参考:jupyter notebook外网访问访问配置, firewall防火墙常用命令
# 设置jupyter登录密码
python -c "import IPython;print(IPython.lib.passwd())"
# 会提示 Enter password
# output sha1:49acd1a985cc:beb1fb6859665bfa721e65e78fc511c41basdasa
# 生成jupyter配置文件
jupyter notebook --generate-config
#生成的config file在/root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.password = 'sha1:<your-sha1-hash-value>'
c.NotebookApp.port = 8888
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
# (不推荐)使用配置自签证书可以:openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout jkey.key -out jcert.pem
#c.NotebookApp.certfile = '/root/jcert.pem'
#c.NotebookApp.keyfile = '/root/jkey.key'
# 开放8888端口, centos默认防火墙是firewall
firewall-cmd --zone=public --add-port=8888/tcp --permanent
systemctl restart firewalld.service
# 最后启动
jupyter notebook --allow-root&
# http://ip:8888 访问即刻
请注意:阿里云一定要到安全组里去开放8888端口!腾讯云不需要

小工具
- telnet
# mac下测试服务器端口是否开发
brew install inetutils
telnet 114.80.67.193 8888
- screen
# centos隧道管理工具,保证关闭ssh连接时运行的命令不会停止
yum install screen
screen -S jupyter
screen -r jupyter
ctrl + a + d
- bzip2
# 参考问题: [conda常见命令](https://www.jianshu.com/p/2f3be7781451):Anaconda3-5.1.0-Linux-x86_64.sh:行350: bunzip2: 未找到命令
yum install -y bzip2
网友评论