使用Anaconda

配置环境变量

如果是windows的话需要去 控制面板\系统和安全\系统\高级系统设置\环境变量\用户变量\PATH 中添加 anaconda的安装目录的Scripts文件夹, 比如我的路径是C:\ProgramData\Anaconda2\Scripts, 看个人安装路径不同需要自己调整.

 没有配置好,下面的conda命令不能使用

查看Anaconda版本

conda --version

 

查看Anaconda包括的包和版本

conda list  或使用 pip list

 

安装和更新库

# 查找软件包

# 罗列出所有可用的版本并在已经安装的版本前加*

conda search beautifulsoup4

~$ conda search beautifulsoup
Fetching package metadata .........
beautifulsoup4               4.4.0                    py27_0  defaults        
                             4.4.0                    py34_0  defaults        
                             4.4.0                    py35_0  defaults        
                             4.4.1                    py27_0  defaults        
                             4.4.1                    py34_0  defaults        
                             4.4.1                    py35_0  defaults        
                             4.5.1                    py27_0  defaults        
                             4.5.1                    py34_0  defaults        
                             4.5.1                    py35_0  defaults        
                             4.5.1                    py36_0  defaults        
                             4.5.3                    py27_0  defaults        
                             4.5.3                    py34_0  defaults        
                             4.5.3                    py35_0  defaults        
                             4.5.3                    py36_0  defaults        
                             4.6.0                    py27_0  defaults        
                             4.6.0                    py34_0  defaults        
                             4.6.0                    py35_0  defaults        
                          *  4.6.0                    py36_0  defaults        

# 安装特定版本软件包

conda install  beautifulsoup4=4.6.0

 安装package

conda install package_name

以安装、更新 scipy 为例

pip install scipy
pip install scipy --upgrade
# 或者
conda install scipy
conda update scipy

# 更新所有库
conda update --all

# 更新 conda 自身
conda update conda

# 更新 anaconda 自身
conda update anaconda

升级aconda

conda update conda

# 升级Anaconda

conda update anaconda

查看python版本

升级python版本

conda update python

卸载第三方包

conda remove <package_name>

或者

pip uninstall <package_name>

 

## Conda的环境管理

同时安装不同版本的Python,并自由切换。

# 创建名为python27的环境,Python2.7版本

conda create --name python27 python=2.7

# 激活环境

activate python27 # for Windows

source activate python27 # for Linux

# 返回默认的环境

deactivate python27 # for Windows

source deactivate python27 # for Linux

# 删除环境

conda remove --name python27 --all

在虚拟环境中使用spyder

1、打开anaconda navigator,选择左侧的环境菜单 Environments,在中间会列出当前已经配置好的各种环境名称;
2、选择新创建的环境,在右边窗口,看看都有哪些packages已经安装,没有安装的,选择All,然后找到后,进行按照,比如按照你所需要的spyder;
3、安装spyder后,在菜单栏里面就有对应的新环境配置的Spyder IDE了。

查看已创建的环境
conda env list

设置国内镜像
# 添加Anaconda的TUNA镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/


# 设置搜索时显示通道地址
conda config --set show_channel_urls yes


参考链接:
http://python.jobbole.com/86236/
http://www.cnblogs.com/harvey888/p/5465452.html


安装whl
pip install ×××.whl

自动生成和安装requirements.txt依赖

生成requirements.txt文件

pip freeze > requirements.txt

安装requirements.txt依赖

pip install -r requirements.txt
 

导入导出环境
如果想要导出当前环境的包信息可以用


conda env export > environment.yaml


将包信息存入yaml文件中.


当需要重新创建一个相同的虚拟环境时可以用


conda env create -f environment.yaml


spyder快捷键:

ctrl+1注释,ctrl+4 块注释 blockcomment Ctrl+4

断点       breakpoint                       F12
关闭所有 close all                           Ctrl+Shift+W
代码补全 code completion               Ctrl+Space
条件断点 conditional breakpoint       Shift+F12
配置       configure                         F6
复制行    copy line                          Ctrl+Alt+Down
调试       debug                             Ctrl+F5


             debug with winpdb          F7


转向定义 go to definition                 Ctrl+G


            go to line                          Ctrl+L
            go to next file                   Ctrl+Shift+Tab
            go to previous file              Ctrl+Tab


运行      run profiler                        F10
            run analysis                       F8


            run                                     F5
            run selection                      F9


            re-run last script              Ctrl+F6


删除行   delte line                         Ctrl+D
寻找      find next                         F3
            fine previous                  Shift+F3
            find text                         Ctrl+F


注释     toggle comment             Ctrl+1
           unblockcomment            Ctrl+4


恢复     redo                                Ctrl+Y


撤销     undo                               Ctrl+U


上次编辑位置last edit location     Ctrl+Alt+Shift+Left


替换文本 replace text                  Ctrl+H 
对文件file操作:


save all                           Ctrl+Alt+S


save as                           Ctrl+Alt+S


save file                           Ctrl+S 


new file                           Ctrl+N


open file                          Ctrl+O


对文件doucument操作:


start of document           Ctrl+Up


end of document             Ctrl+Down


对line操作:


move line down              Alt+Down
move line up                   Alt+Up


duplicate line                  Ctrl+Alt+Up


show/hide outline           Ctrl+Alt+O


对光标位置操作:
previous cursor position  Ctrl+ALT+Left
next cursor position        Ctrl+Alt+Right  


对project操作:


inspect current object Ctrl+I


show/hide project explorer Ctrl+Alt+P

 
原文地址:https://www.cnblogs.com/ttrrpp/p/6579961.html