1. 下载镜像
cd /tmp
curl -O https://repo.anaconda.com/archive/Anaconda3.5.2.0-Linux-x86_64.sh
开始安装
- 在/opt目录下载或者上传Anaconda3.5.2.0-Linux-x86_64.sh
- 安装Anaconda
sh Anaconda3-5.2.0-Linux-x86_64.sh
- 默认安装在/root/anaconda3下面
- 配置环境变量
vim ~/.bashrc
export PATH=/root/anaconda3/bin:$PATH
- 立即生效
source ~/.bashrc
- 生成jupyter notebook配置文件
jupyter notebook --generate-config --allow-root
- 安装notebook
conda install notebook
- 生成密码
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2019, 16:14:56)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.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:1bd02967d36a:4cb1f312446313eb78ba15a29b6b3587eb75ae0d'
In [3]:
- 修改配置文件
vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:1bd02967d36a:4cb1f312446313eb78ba15a29b6b3587eb75ae0d'
c.NotebookApp.open_browser = True
c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
c.NotebookApp.notebook_dir = u'/search/autotest/jupyter_dir' 即设置jupyter启动后默认的根目录
如果在docker里启动需修改下面的设置
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True
- 启动
nohup jupyter notebook --allow-root &
conda管理环境
- 设置conda环境变量
echo ". /root/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
sudo ln -s /root/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
echo "conda activate" >> ~/.bashrc
export PATH="/root/anaconda3/bin:$PATH"
source ~/.bashrc
- 创建一个虚拟环境
conda create --n ml python=3.6 ipykernel
- 激活环境
source activate ml
python -m ipykernel install --user --name ml --display-name "ml"
- 安装扩展包
conda install numpy pandas ...
- 重启jupyter