-
通过 wget 下载 anaconda 安装包
wget https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh
利用 bash 命令安装到 anaconda 文件夹下
bash Anaconda3-5.3.1-Linux-x86_64.sh -p anaconda/ -u
conda测试环境
输入命令conda --version,有版本信息则说明安装成功,否则可能没有将conda加入环境变量中,需执行:
export PATH=~/anaconda3/bin:$PATH
source ~/.bashrc增加conda的镜像(这边以中科大镜像为例,也可增加清华镜像)
conda config --add channels Index of /anaconda/pkgs/free/ | 北京外国语大学开源软件镜像站 | BFSU Open Source Mirror去掉conda的镜像
conda config --remove channels Index of /anaconda/pkgs/free/ | 北京外国语大学开源软件镜像站 | BFSU Open Source Mirrorconda创建虚拟环境
conda create -n env_name python=3.5
conda激活虚拟环境
conda activate env_name
conda修复本地环境
conda upgrade --all
jupyter环境
jupyter安装nbextensions
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user -
- 设置jupyter notebook密码:
- jupyter notebook password
- 在ipython中获取hash密码:
- from notebook.auth import passwd
- passwd()
- 保存新生成的密码
- 设置jupyter设置文件
- 生成配置文件
- jupyter notebook --generate-config
- 打开配置文件
- vim /root/.jupyter/jupyter_notebook_config.py
- 设置行号
- :set nu
- 设置文件
- c.NotebookApp.notebook_dir = '/root/notebook' # notebook默认目录
- c.NotebookApp.ip = 'xx.xx.xxx.xx' # 设置登录ip地址,即本机地址
- c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
- c.NotebookApp.open_browser = False
- 生成配置文件
- 从控制台直接启动jupyter
- jupyter notebook password
- jupyter notebook --allow-root
- 指定启动端口
- jupyter notebook --port <port_number>
- 后台运行jupyter
- nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
- jupyter登录:
- jupyter登录地址:http://xx.xx.xxx.xx:8888/tree?
- 密码:u'sha1:bcd259ccf...<your hashed password here>'
- jupyter安装nbextension
- jupyter contrib nbextension install --user --skip-running-check
- 或者执行以下命令:
- pip install jupyter_contrib_nbextensions -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
- jupyter contrib nbextension install --user
- 查询jupyter运行进程
- ps -ef | grep jupyter
- 关闭运行中的进程
- kill -9 <PID number>
- 对于好不容易配置好的环境,将其中的包,版本号等导出作为记录是很重要的一件事,这便于我们对环境的安装进行再次的复现。
- 导出已有环境:
- conda env export > environment.yaml
- 环境会被保存在 environment.yaml文件中。
- 当我们想再次创建该环境,或根据别人提供的.yaml文件复现环境时,可以:
- conda env create -f environment.yaml