文章目录

  • anaconda的安装及环境配置
  • 下载
  • 安装
  • 配置环境变量
  • 检查是否安装成功
  • 添加中国镜像
  • 添加或移除通道
  • anaconda创建新的环境及相关命令
  • jupyter notebook代码自动补全、单词高亮
  • 改变jupyter notebook注释的字体、颜色等
  • jupyter notebook显示行号
  • jupyter notebook相关命令


anaconda的安装及环境配置

参考:【Anaconda教程01】怎么安装Anaconda3 - 知乎 (zhihu.com)

下载

Index of /anaconda/archive/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

安装

  • 选择all users
  • 不要勾选添加PATH这一项

配置环境变量

此电脑——属性——高级系统设置——环境变量——系统变量——path——编辑——新建

E:\Anaconda(Python需要)
E:\Anaconda\Scripts(conda自带脚本)
E:\Anaconda\Library\mingw-w64\bin(使用C with python的时候)
E:\Anaconda\Library\bin(jupyter notebook动态库)

检查是否安装成功

  • 在cmd中输入python,查看是否有python环境
  • 在cmd中输入conda --version,查看是否有conda环境
  • 点击Anaconda Navigator看能否成功进入界面

添加中国镜像

在Anaconda prompt中操作:

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 设置搜索时显示通道
conda config --set show_channel_urls yes
# 查看通道
conda config --show channels
# 移除
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

anaconda创建新的环境及相关命令

参考:Anacoda 介绍、安装、环境切换 - wmxl 

conda env list # 列出 conda 管理的环境
conda create -n hackday python=2.7.8 # 创建名为 hackday 的环境,并指定 python 版本为 2.7.8
conda activate hackday # 进入 hackday 环境
conda env list # 列出当前环境所有包及其相关信息
conda install numpy=1.14.5 # 安装版本为 1.14.5 的 numpy 包 
conda updata numpy # 更新 numpy 包
activate # 切换到 base 环境
conda remove numpy # 卸载 numpy 包
conda remove -n hackday --all # 删除 hackday 环境及下属所有包
conda env export > environment.yaml # 导出当前环境的包信息
conda env create -f environment.yaml # 用配置文件创建新的虚拟环境

jupyter notebook代码自动补全、单词高亮

参考:https://github.com/ipython-contrib/jupyter_contrib_nbextensions/blob/master/README.md 打开 Anaconda prompt,依次运行下面的命令

# 安装插件
conda install -c conda-forge jupyter_contrib_nbextensions
# 配置
jupyter nbextensions_configurator enable --user

发现顶部菜单栏多了nbextensions选项

  • Highlight selected word # 单词高亮
  • Hinterland # 代码自动补全

改变jupyter notebook注释的字体、颜色等

参考:https://www.zhihu.com/question/40012144/answer/124731496 在python的安装目录下:

/lib/site-packages/notebook/static/custom/

找到custom.css 修改一下文件即可,我添加了下面的命令,其中包含字体、颜色。

span.cm-comment {font-family:  Consolas !important; font-style:normal !important; color:#FF4500 !important;}

python excel 怎么获取字体的颜色 python字体颜色在哪里设置_anaconda


修改后的效果如图:

python excel 怎么获取字体的颜色 python字体颜色在哪里设置_python_02


颜色可以参考HTML 颜色值

jupyter notebook显示行号

菜单栏 View–Toggle Line Numbers

jupyter notebook相关命令

jupyter kenelspect list # 查看内核情况