86 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			86 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| 
								 | 
							
								# 工作环境
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 目录
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								`mkdir /data && mkdir /data/jupyter && cd /data/jupyter`
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Conda
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 安装
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								#下载最新版本
							 | 
						||
| 
								 | 
							
								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
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 配置
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								#**更换清华镜像源**
							 | 
						||
| 
								 | 
							
								conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/  
							 | 
						||
| 
								 | 
							
								conda config --set show\_channel\_urls yes
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# Jupyter
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 安装
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								#安装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
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 配置
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								#生成配置
							 | 
						||
| 
								 | 
							
								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
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								mkdir ~/.pip
							 | 
						||
| 
								 | 
							
								%%writefile ~/.pip/pip.conf
							 | 
						||
| 
								 | 
							
								[global]
							 | 
						||
| 
								 | 
							
								index-url = http://mirrors.tencentyun.com/pypi/simple
							 | 
						||
| 
								 | 
							
								trusted-host = mirrors.tencentyun.com
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## 启动
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```shell
							 | 
						||
| 
								 | 
							
								#无后台启动
							 | 
						||
| 
								 | 
							
								nohup jupyter notebook --allow-root > /data/jupyter.log 2>&1 &
							 | 
						||
| 
								 | 
							
								[Unit]
							 | 
						||
| 
								 | 
							
								Description=Jupyter Notebook
							 | 
						||
| 
								 | 
							
								After=network.target
							 | 
						||
| 
								 | 
							
								[Service]
							 | 
						||
| 
								 | 
							
								Type=simple
							 | 
						||
| 
								 | 
							
								ExecStart=nohup jupyter notebook --allow-root > /data/jupyter.log 2>&1 &
							 | 
						||
| 
								 | 
							
								#文件路径名
							 | 
						||
| 
								 | 
							
								Restart=always
							 | 
						||
| 
								 | 
							
								RestartSec=10
							 | 
						||
| 
								 | 
							
								[Install]
							 | 
						||
| 
								 | 
							
								WantedBy=multi-user.target
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 |