conda --help usage: conda [-h] [-V] command ... conda is a tool for managing and deploying applications, environments and packages. Options: positional arguments: command info Display information about current conda install. help Displays a list of available conda commands and their help strings. list List linked packages in a conda environment. search Search for packages and display their information. The input is a Python regular expression. To perform a search with a search string that starts with a -, separate the search from the options with --, like 'conda search -- -h'. A * in the results means that package is installed in the current environment. A . means that package is not installed but is cached in the pkgs directory. create Create a new conda environment from a list of specified packages. install Installs a list of packages into a specified conda environment. update Updates conda packages to the latest compatible version. This command accepts a list of package names and updates them to the latest versions that are compatible with all other packages in the environment. Conda attempts to install the newest versions of the requested packages. To accomplish this, it may update some packages that are already installed, or install additional packages. To prevent existing packages from updating, use the --no-update-deps option. This may force conda to install older versions of the requested packages, and it does not prevent additional dependency packages from being installed. If you wish to skip dependency checking altogether, use the '--force' option. This may result in an environment with incompatible packages, so this option must be used with great caution. upgrade Alias for conda update. See conda update --help. remove Remove a list of packages from a specified conda environment. uninstall Alias for conda remove. See conda remove --help. config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\WQBin\.condarc) by default. clean Remove unused packages and caches. package Low-level conda package utility. (EXPERIMENTAL) optional arguments: -h, --help Show this help message and exit. -V, --version Show the conda version number and exit. other commands, such as "conda build", are available when additional conda packages (e.g. conda-build) are installed
根据“conda -h”的提示信息,修改配置文件(若是没有,能够建立)python
conda config --show 查看当前全部配置 conda config --show-sources 查看当前使用源 conda config --remove channels 删除指定源 conda config --add channels 加指定源
proxy_servers: http: http://10.144.1.10:8080 https: http://10.144.1.10:8080
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --set show_channel_urls yes
默认状况下,Conda建立的新环境以及过往安装的模块缓存都存储在用户目录。
默认信息不会在Conda(user-specific)配置文件“$HOME/.condarc”中体现,但可经过"conda info"查看,包括默认环境路径、默认缓存路径、Conda源设置等。
添加或修改“$HOME/.condarc”中的“env_dirs”和“pkgs_dirs”配置项,能够设置conda环境和缓存(envs directories 和 package cache)的默认路径。
按顺序第一个路径做为默认存储路径,搜索环境和缓存时按前后顺序在各目录中查找。git
例如:在“$HOME/.condarc”中添加以下路径shell
解释以下:express
按顺序第一个路径做为默认存储路径,搜索环境和缓存时按前后顺序在各目录中查找缓存
若是要改动有两种方法bash
方法1、在“$HOME/.condarc”中添加以下路径app
envs_dirs: - D:\xxx\xxx\envs # 按顺序第一个路径做为默认存储路径,搜索环境和缓存时按前后顺序在各目录中查找 - C:\Users\xxx\AppData\Local\conda\conda\envs - C:\Users\xxx\.conda\envs pkgs_dirs: - D:\xxx\anaconda3\pkgs - C:\Users\xxx\AppData\Local\conda\conda\pkgs
方法2、python2.7
使用conda命令指定存放路径:工具
conda config --add envs_dirs <环境位置绝对路径> # 添加环境位置 conda config --add pkgs_dirs <包位置绝对路径> # 添加包位置
conda install <package_name> 安装包 conda install numpy scipy pandas 同时安装多个包 conda install numpy=1.10 安装包的指定版本 conda install anaconda 在当前环境安装anaconda集合包 conda remove <package_name> 移除包 conda update <package_name> 升级包 conda list 查看当前环境已安装的包信息 conda search <package_name> 查询包信息 conda search <search_term> 模糊查询包信息 conda install --name <env_name> <package_name> 在指定环境安装的包信息 conda remove --name <env_name> <package_name> 移除指定环境的包 conda update --name <env_name> <package_name> 升级指定环境的包 conda list --name <env_name> 查看指定环境的已安装的包信息 conda update conda 更新conda conda update anaconda 更新anaconda conda update python 更新Python
注意:conda和pip都是对当前环境进行安装、升级和卸载包的操做。
ui
use_pip:
true
conda create --name <env_name> <list of packages> 建立新环境 conda create --name testpy2 python=2.7 pandas 建立名为testpy2的运行环境,并安装pandas包及其依赖包 conda create --name testpy36 python=3.6 anaconda 建立名为testpy36的运行环境,并安装anaconda集合包(conda默认环境) conda env remove --name <env_name> 删除环境 conda env list 显示全部的环境 conda info 显示当前安装的conda信息 conda info --envs 显示全部运行环境 source activate <env_name> 激活(进入)环境 source deactivate 去激活(退出)当前环境
conda env export > BackupEnv.yaml 将当前运行环境的package信息导出到名为BackupEnv的YAML文件
conda env create --force BackupEnv.yaml 使用YAML文件建立运行环境
$ py --version # 当前默认python版本 Python 3.7.1 $ conda create --name py27 python=2.7 pandas # 建立名为py27的运行环境,并安装pandas包及其依赖包 Solving environment: done ## Package Plan ## environment location: D:\app\anaconda3\envs\py27 # 建立的运行环境的所在目录 added / updated specs: # conda仅安装pandas和python2.7相关的必须项(pandas的依赖项,python2.7, pip等) - pandas - python=2.7 The following packages will be downloaded: # 将要下载当前没有的安装包 package | build ---------------------------|----------------- vc-9 | h7299396_1 3 KB python-dateutil-2.7.5 | py27_0 275 KB pandas-0.23.4 | py27h39f3610_0 8.8 MB pytz-2018.7 | py27_0 250 KB certifi-2018.10.15 | py27_0 139 KB setuptools-40.5.0 | py27_0 653 KB numpy-root-1.15.4 | py27h2753ae9_0 3.8 MB pip-18.1 | py27_0 1.8 MB vs2008_runtime-9.00.30729.1| hfaea7d5_1 1017 KB wincertstore-0.2 | py27hf04cefb_0 13 KB python-2.7.15 | h2880e7c_3 20.3 MB six-1.11.0 | py27_1 21 KB numpy-1.15.4 | py27hbe4291b_0 36 KB mkl_fft-1.0.6 | py27hac4a418_0 120 KB wheel-0.32.2 | py27_0 52 KB ------------------------------------------------------------ Total: 37.1 MB The following NEW packages will be INSTALLED: # 将要安装的包 blas: 1.0-mkl certifi: 2018.10.15-py27_0 icc_rt: 2017.0.4-h97af966_0 intel-openmp: 2019.0-118 mkl: 2019.0-118 mkl_fft: 1.0.6-py27hac4a418_0 numpy: 1.15.4-py27hbe4291b_0 numpy-root: 1.15.4-py27h2753ae9_0 pandas: 0.23.4-py27h39f3610_0 pip: 18.1-py27_0 python: 2.7.15-h2880e7c_3 python-dateutil: 2.7.5-py27_0 pytz: 2018.7-py27_0 setuptools: 40.5.0-py27_0 six: 1.11.0-py27_1 vc: 9-h7299396_1 vs2008_runtime: 9.00.30729.1-hfaea7d5_1 wheel: 0.32.2-py27_0 wincertstore: 0.2-py27hf04cefb_0 Proceed ([y]/n)? y Downloading and Extracting Packages vc-9 | 3 KB | ######################################################################## | 100% python-dateutil-2.7. | 275 KB | ######################################################################## | 100% pandas-0.23.4 | 8.8 MB | ######################################################################## | 100% pytz-2018.7 | 250 KB | ######################################################################## | 100% certifi-2018.10.15 | 139 KB | ######################################################################## | 100% setuptools-40.5.0 | 653 KB | ######################################################################## | 100% numpy-root-1.15.4 | 3.8 MB | ######################################################################## | 100% pip-18.1 | 1.8 MB | ######################################################################## | 100% vs2008_runtime-9.00. | 1017 KB | ######################################################################## | 100% wincertstore-0.2 | 13 KB | ######################################################################## | 100% python-2.7.15 | 20.3 MB | ######################################################################## | 100% six-1.11.0 | 21 KB | ######################################################################## | 100% numpy-1.15.4 | 36 KB | ######################################################################## | 100% mkl_fft-1.0.6 | 120 KB | ######################################################################## | 100% wheel-0.32.2 | 52 KB | ######################################################################## | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use: # > activate py27 # # To deactivate an active environment, use: # > deactivate # # * for power-users using bash, you must source # $ conda env list # 显示全部运行环境 # conda environments: # root * D:\app\anaconda3 # 星号表示是当前运行环境 py27 D:\app\anaconda3\envs\py27 $ source activate py27 # 进入py27运行环境 (py27) $ conda env list # conda environments: # root D:\app\anaconda3 py27 * D:\app\anaconda3\envs\py27 # 星号表示是当前运行环境 (py27) $ py --version Python 3.7.1 (py27) # 括号中显示当前的运行环境 $ conda info # 显示conda信息 active environment : py27 active env location : D:\app\anaconda3\envs\py27 shell level : 1 user config file : C:\Users\WQBin\.condarc populated config files : C:\Users\WQBin\.condarc conda version : 4.5.11 conda-build version : 3.16.2 python version : 3.7.1.final.0 root environment : D:\app\anaconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/win-64 https://repo.anaconda.com/pkgs/pro/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : D:\app\anaconda3\pkgs C:\Users\WQBin\AppData\Local\conda\conda\pkgs envs directories : D:\app\anaconda3\envs C:\Users\WQBin\AppData\Local\conda\conda\envs C:\Users\WQBin\.conda\envs platform : win-64 user-agent : conda/4.5.11 requests/2.20.0 CPython/3.7.1 Windows/7 Windows/6.1.7601 administrator : False netrc file : None offline mode : False (py27) $ source deactivate # 退出当前运行环境 $ conda env list # conda environments: # root * D:\app\anaconda3 # 星号表示是当前运行环境 py27 D:\app\anaconda3\envs\py27 $ conda env remove --name py27 # 删除运行环境 Remove all packages in environment D:\app\anaconda3\envs\py27: ## Package Plan ## environment location: D:\app\anaconda3\envs\py27 The following packages will be REMOVED: blas: 1.0-mkl certifi: 2018.10.15-py27_0 icc_rt: 2017.0.4-h97af966_0 intel-openmp: 2019.0-118 mkl: 2019.0-118 mkl_fft: 1.0.6-py27hac4a418_0 numpy: 1.15.4-py27hbe4291b_0 numpy-root: 1.15.4-py27h2753ae9_0 pandas: 0.23.4-py27h39f3610_0 pip: 18.1-py27_0 python: 2.7.15-h2880e7c_3 python-dateutil: 2.7.5-py27_0 pytz: 2018.7-py27_0 setuptools: 40.5.0-py27_0 six: 1.11.0-py27_1 vc: 9-h7299396_1 vs2008_runtime: 9.00.30729.1-hfaea7d5_1 wheel: 0.32.2-py27_0 wincertstore: 0.2-py27hf04cefb_0 Proceed ([y]/n)? y $ conda env list # conda environments: # root * D:\app\anaconda3 $