anaconda的一些使用
虚拟环境操作
参看存在的虚拟环境
conda evn list
创造虚拟环境
conda create -n 环境名 python=3.6
删除虚拟环境操作
conda remove -n 环境名 --all
激活环境
activate 环境名
jupyter 的使用
安装jupyter
conda install jupyter
jupyter默认配置
jupyter notebook --generate-config --allow-root
vim /home/xjl/.jupyter/jupyter_notebook_config.py
找到c.NotebookApp.notebook_dir
,并修改其为你想要的路径
在conda的虚拟环境下,安装nb_conda
包,同时也要安装jupyter
conda install nb_conda
启动jupyter
jupyter notebook
常用指令如下:
命令模式 (按键 Esc 开启)快捷键:
Enter : 转入编辑模式
Shift-Enter : 运行本单元,选中下个单元
Ctrl-Enter : 运行本单元
Alt-Enter : 运行本单元,在其下插入新单元
Y : 单元转入代码状态
M :单元转入markdown状态
R : 单元转入raw状态
Up : 选中上方单元
K : 选中上方单元
Down : 选中下方单元
J : 选中下方单元
Shift-K : 扩大选中上方单元
Shift-J : 扩大选中下方单元
A : 在上方插入新单元
B : 在下方插入新单元
X : 剪切选中的单元
C : 复制选中的单元
Shift-V : 粘贴到上方单元
V : 粘贴到下方单元
Z : 恢复删除的最后一个单元
D,D : 删除选中的单元
Shift-M : 合并选中的单元
Ctrl-S : 文件存盘
S : 文件存盘
L : 转换行号
O : 转换输出
Shift-O : 转换输出滚动
Esc : 关闭页面
Q : 关闭页面
H : 显示快捷键帮助
I,I : 中断Notebook内核
0,0 : 重启Notebook内核
Shift : 忽略
Shift-Space : 向上滚动
Space : 向下滚动
编辑模式 ( Enter 键启动)下快捷键
Tab : 代码补全或缩进
Shift-Tab : 提示
Ctrl-] : 缩进
Ctrl-[ : 解除缩进
Ctrl-A : 全选
Ctrl-Z : 复原
Ctrl-Shift-Z : 再做
Ctrl-Y : 再做
Ctrl-Home : 跳到单元开头
Ctrl-Up : 跳到单元开头
Ctrl-End : 跳到单元末尾
Ctrl-Down : 跳到单元末尾
Ctrl-Left : 跳到左边一个字首
Ctrl-Right : 跳到右边一个字首
Ctrl-Backspace : 删除前面一个字
Ctrl-Delete : 删除后面一个字
Esc : 进入命令模式
Ctrl-M : 进入命令模式
Shift-Enter : 运行本单元,选中下一单元
Ctrl-Enter : 运行本单元
Alt-Enter : 运行本单元,在下面插入一单元
Ctrl-Shift-- : 分割单元
Ctrl-Shift-Subtract : 分割单元
Ctrl-S : 文件存盘
Shift : 忽略
Up : 光标上移或转入上一单元
Down :光标下移或转入下一单元
报错解决
1.conda install 报错
An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/main/win-64/repodata.json.bz2 (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x00000247EB8CC1D0>, 'Connection to repo.continuum.io timed out. (connect timeout=9.15)'))",),)
终端下分别输入
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
或者去文件夹C:\user\你的用户名\.condarc
下修改为上面的链接
2. 安装nb-conda报错
报错Traceback (most recent call last): File "/home/cc/install/anaconda3/bin/jupyter-notebook", line 7, in <module> from notebook.notebookapp import main File "/home/cc/install/anaconda3/lib/python3.6/site-packages/notebook/__init__.py", line 25, in <module> from .nbextensions import install_nbextension File "/home/cc/install/anaconda3/lib/python3.6/site-packages/notebook/nbextensions.py", line 27, in <module> from jupyter_core.utils import ensure_dir_exists ImportError: cannot import name 'ensure_dir_exists'
这里需要更新jupyter
终端下输入
conda update jupyter_core jupyter_client