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 $