1.9 KiB
1.9 KiB
工作环境
目录
mkdir /data/jupyter && cd /data/jupyter
Conda
安装
#下载最新版本
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod 777 Miniconda3-latest-Linux-x86_64.sh #给执行权限
bash Miniconda3-latest-Linux-x86_64.sh #运行
#环境变量生效
source ~/.bashrc
配置
#**更换清华镜像源**
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show\_channel\_urls yes
Jupyter
安装
#安装jupyter
conda install jupyter notebook
#创建环境
conda create -n py3 python=3.7
conda activate py3
conda install notebook ipykernel
python -m ipykernel install --user --name py3 --display-name="python3.7"
#退出环境
conda deactivate
配置
#生成配置
jupyter notebook --generate-config
#修改配置
c.NotebookApp.notebook_dir = '/data/jupyter'
c.NotebookApp.ip = '*'
c.NotebookApp.allow_root = True
c.NotebookApp.open_browser = True
c.NotebookApp.password = u'sha1:4f96fe6d1725:2e8650de1b1b7dbae474c7de97b3b5484f2fe537' #输入上面加密后得到的密文
PIP
mkdir ~/.pip
%%writefile ~/.pip/pip.conf
[global]
index-url = http://mirrors.tencentyun.com/pypi/simple
trusted-host = mirrors.tencentyun.com
启动
#无后台启动
nohup jupyter notebook --allow-root > /data/jupyter.log 2>&1 &
%%writefile /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter Notebook
After=network.target
[Service]
Type=simple
#ExecStart 是执行文件
ExecStart=/root/miniconda3/bin/jupyter-notebook --config=/root/.jupyter/jupyter_notebook_config.py --allow-root
#文件路径名
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
ps -a 显示进程pid
kill -9 pid 终止进程
#开机自启
systemctl enable jupyter.service
service jupyter start