换源
清华anaconda镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/# 设置搜索时显示通道地址conda config --set show_channel_urls yes
conda额外库,第三方提供
# pytorchconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/# 安装时PyTorch,官网给的安装命令需要去掉最后的-c pytorch,才能使用清华源# conda-forgeconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/# msys2conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/# biocondaconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/# menpoconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/# 设置搜索时显示通道地址conda config --set show_channel_urls yes
中科大anaconda镜像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/conda config --set show_channel_urls yes
换回默认源
conda config --remove-key channels
更新版本
# condaconda update conda# anaconda(升级anaconda前需要先升级conda)conda update anaconda# anaconda-navigatorconda update anaconda-navigator# spyderconda update spyder# 所有包conda update --all# 尽量避免使用conda update --all命令,可能会出现部分包降级的问题
jupyter配置
安装
conda install jupyter notebook=6.1.5 # 可以在后面加上版本
nbextension 插件安装
安装后会jupyter主页出现 nbextension 标签页,从中选择要安装的插件
conda install -c conda-forge jupyter_contrib_nbextensionsjupyter contrib nbextension install --user
jupyter按tab无法补齐解决方案
- jupyter notebook 降级为 6.1.5
- jedi:0.18.0 —— 降级为:0.17.2 (自动提示环境包)
多环境切换
安装kernel
conda activate <环境名称>conda install ipykernelpython -m ipykernel install --user --name env_name --display-name "kernel_name"
查看、删除已有的kernel
jupyter kernelspec listjupyter kernelspec remove kernelname
以上的命令删除仅仅是配置文件,并没有卸载相应虚拟环境的ipykernel,因此若要再次安装相应python虚拟环境的kernel,只需激活虚拟环境
python -m ipykernel install --name kernelname
远程服务器配置
生成配置文件
jupyter notebook --generate-config
生成密码
打开ipython,创建一个密文的密码: 把生成的密文‘sha:ce…’复制下来
In [1]: from notebook.auth import passwdIn [2]: passwd()Enter password:Verify password:Out[2]: 'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'
修改默认配置文件
vim ~/.jupyter/jupyter_notebook_config.py
进行如下修改:
c.NotebookApp.ip='*'c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'c.NotebookApp.open_browser = Truec.NotebookApp.port =8888 #随便指定一个端口
远程访问
方位链接:http://address_of_remote:8888
