资料: https://mirrors.bfsu.edu.cn/help/anaconda/
参考: https://www.jianshu.com/p/edaa744ea47d

Windows 版本

conda 简介

Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。 Conda 是为 Python 程序创建的,适用于 Linux,OS X 和Windows,也可以打包和分发其他软件。

Anaconda 与 miniconda,前者包括较多的人工智能、数据分析、深度学习的包,都有 conda,用于包管理,环境管理。

本次使用的是 miniconda

下载地址: https://docs.conda.io/en/latest/miniconda.html

根据提示安装即可

配置镜像

都说清华镜像好,那就清华的吧
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/cloud/conda-forge/
conda config —add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

  1. # 查看版本
  2. PS D:\devTools\Python\virtual_env> conda --version
  3. conda 4.11.0
  4. PS D:\devTools\Python\virtual_env>
  5. PS D:\devTools\Python\virtual_env>
  6. # 添加清华镜像
  7. PS D:\devTools\Python\virtual_env> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  8. PS D:\devTools\Python\virtual_env> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  9. PS D:\devTools\Python\virtual_env> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  10. PS D:\devTools\Python\virtual_env> conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  11. PS D:\devTools\Python\virtual_env>

查看镜像

conda config —set show_channel_urls yes
conda config —get channels

  1. PS D:\devTools\Python\virtual_env> conda config --set show_channel_urls yes
  2. PS D:\devTools\Python\virtual_env>
  3. PS D:\devTools\Python\virtual_env> conda config --get channels
  4. --add channels 'defaults' # lowest priority
  5. --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
  6. --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'
  7. --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'
  8. --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/' # highest priority
  9. PS D:\devTools\Python\virtual_env>
  10. PS D:\devTools\Python\virtual_env>

conda 的 help

conda —help

  1. PS D:\devTools\Python\virtual_env> conda --help
  2. usage: conda-script.py [-h] [-V] command ...
  3. conda is a tool for managing and deploying applications, environments and packages.
  4. Options:
  5. positional arguments:
  6. command
  7. clean Remove unused packages and caches.
  8. compare Compare packages between conda environments.
  9. config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file
  10. (C:\Users\DELL\.condarc) by default.
  11. create Create a new conda environment from a list of specified packages.
  12. help Displays a list of available conda commands and their help strings.
  13. info Display information about current conda install.
  14. init Initialize conda for shell interaction. [Experimental]
  15. install Installs a list of packages into a specified conda environment.
  16. list List linked packages in a conda environment.
  17. package Low-level conda package utility. (EXPERIMENTAL)
  18. remove Remove a list of packages from a specified conda environment.
  19. uninstall Alias for conda remove.
  20. run Run an executable in a conda environment. [Experimental]
  21. search Search for packages and display associated information. The input is a MatchSpec, a query language for conda packages. See
  22. examples below.
  23. update Updates conda packages to the latest compatible version.
  24. upgrade Alias for conda update.
  25. optional arguments:
  26. -h, --help Show this help message and exit.
  27. -V, --version Show the conda version number and exit.
  28. conda commands available from other packages:
  29. content-trust
  30. env
  31. PS D:\devTools\Python\virtual_env>

环境管理

conda env list 查看安装的环境

conda env list

  1. PS D:\devTools\Python\virtual_env> conda env list
  2. # conda environments:
  3. #
  4. base * D:\devTools\Python\Miniconda3
  5. PS D:\devTools\Python\virtual_env>
  1. 新环境只有一个 base env,建议不要删除。

conda create -n env_name python=python_version 创建env

conda create -n python36 python=3.6 会默认安装 python3.6 当期最新版本

  1. PS D:\devTools\Python\virtual_env> conda create -n python36 python=3.6
  2. Collecting package metadata (current_repodata.json): done
  3. Solving environment: done
  4. ## Package Plan ##
  5. environment location: D:\devTools\Python\Miniconda3\envs\python36
  6. added / updated specs:
  7. - python=3.6
  8. The following packages will be downloaded:
  9. package | build
  10. ---------------------------|-----------------
  11. certifi-2020.6.20 | pyhd3eb1b0_3 155 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  12. pip-20.0.2 | py36_1 1.9 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  13. python-3.6.15 |h39d44d4_0_cpython 18.9 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  14. python_abi-3.6 | 2_cp36m 4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  15. setuptools-49.6.0 | py36ha15d459_3 921 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  16. ucrt-10.0.20348.0 | h57928b3_0 1.2 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  17. vc-14.2 | hb210afc_6 13 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  18. vs2015_runtime-14.29.30037 | h902a5da_6 1.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  19. wheel-0.37.1 | pyhd8ed1ab_0 31 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  20. wincertstore-0.2 |py36ha15d459_1006 15 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  21. ------------------------------------------------------------
  22. Total: 24.4 MB
  23. The following NEW packages will be INSTALLED:
  24. done
  25. #
  26. # To activate this environment, use
  27. #
  28. # $ conda activate python36
  29. #
  30. # To deactivate an active environment, use
  31. #
  32. # $ conda deactivate
  33. PS D:\devTools\Python\virtual_env>

当然,安装python环境的时候可以同时指定需要的包,比如 Django、flask、Djangorestframework 等,比如:
conda create -n python27 python=2.7 django djangorestframework

  1. PS D:\devTools\Python\virtual_env> conda create -n python27 python=2.7 django djangorestframework
  2. Collecting package metadata (current_repodata.json): done
  3. Solving environment: done
  4. ## Package Plan ##
  5. environment location: D:\devTools\Python\Miniconda3\envs\python27
  6. added / updated specs:
  7. - django
  8. - djangorestframework
  9. - python=2.7
  10. The following packages will be downloaded:
  11. package | build
  12. ---------------------------|-----------------
  13. django-1.11.25 | py27h85ba907_0 4.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  14. djangorestframework-3.6.3 | py27_0 964 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  15. pip-20.0.2 | py27_1 1.9 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  16. python-2.7.15 |h2880e7c_1011_cpython 20.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  17. python_abi-2.7 | 1_cp27m 4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  18. pytz-2019.3 | py_0 237 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  19. setuptools-36.4.0 | py27_1 525 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  20. vc-9 | h2eaa2aa_6 5 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  21. vs2008_runtime-9.0.30729.6161| 0 1.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  22. wincertstore-0.2 | py27_1003 13 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  23. ------------------------------------------------------------
  24. Total: 29.3 MB
  25. The following NEW packages will be INSTALLED:
  26. certifi anaconda/pkgs/main/noarch::certifi-2020.6.20-pyhd3eb1b0_3
  27. done
  28. #
  29. # To activate this environment, use
  30. #
  31. # $ conda activate python27
  32. #
  33. # To deactivate an active environment, use
  34. #
  35. # $ conda deactivate
  36. PS D:\devTools\Python\virtual_env>

后面的包没有指定版本,会根据python版本选择的。

conda activate env_name 激活环境

conda activate python27

  1. C:\Users\DELL>echo %OS%
  2. Windows_NT
  3. C:\Users\DELL>conda env list
  4. # conda environments:
  5. #
  6. base * D:\devTools\Python\Miniconda3
  7. python27 D:\devTools\Python\Miniconda3\envs\python27
  8. python36 D:\devTools\Python\Miniconda3\envs\python36
  9. C:\Users\DELL>conda activate python27
  10. (python27) C:\Users\DELL>

注意: 我的 Windows power shell 无法执行成功,要换 cmd 执行;
激活之后,前面会显示env名称,此次激活的就是 Python27,显示在了前面。
现在就可以像原来安装的对应版本进行使用 python 了。

简单使用(像本地的python一样,pip管理包)

  1. (python27) C:\Users\DELL>python -V
  2. Python 2.7.15
  3. (python27) C:\Users\DELL>pip --version
  4. pip 20.0.2 from D:\devTools\Python\Miniconda3\envs\python27\lib\site-packages\pip (python 2.7)
  5. (python27) C:\Users\DELL>
  6. (python27) C:\Users\DELL>pip list
  7. DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
  8. Package Version
  9. ------------------- ---------
  10. certifi 2020.6.20
  11. Django 1.11.25
  12. djangorestframework 3.6.3
  13. pip 20.0.2
  14. pytz 2019.3
  15. setuptools 36.4.0
  16. wheel 0.37.1
  17. wincertstore 0.2
  18. (python27) C:\Users\DELL>

使用 conda 进行包管理

  1. (python27) C:\Users\DELL>conda list # 查看已安装的包
  2. # packages in environment at D:\devTools\Python\Miniconda3\envs\python27:
  3. #
  4. # Name Version Build Channel
  5. certifi 2020.6.20 pyhd3eb1b0_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  6. django 1.11.25 py27h85ba907_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  7. djangorestframework 3.6.3 py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  8. pip 20.0.2 py27_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  9. python 2.7.15 h2880e7c_1011_cpython https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  10. python_abi 2.7 1_cp27m https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  11. pytz 2019.3 py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  12. setuptools 36.4.0 py27_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  13. vc 9 h2eaa2aa_6 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  14. vs2008_runtime 9.0.30729.6161 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  15. wheel 0.37.1 pyhd8ed1ab_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  16. wincertstore 0.2 py27_1003 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  17. (python27) C:\Users\DELL>
  18. (python27) C:\Users\DELL>conda install drf_yasg # 安装 drf_yasg
  19. Collecting package metadata (current_repodata.json): done
  20. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  21. Collecting package metadata (repodata.json): done
  22. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  23. PackagesNotFoundError: The following packages are not available from current channels:
  24. - drf_yasg
  25. Current channels:
  26. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-64
  27. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  28. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  29. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  30. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  31. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  32. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  33. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  34. - https://repo.anaconda.com/pkgs/main/win-64
  35. - https://repo.anaconda.com/pkgs/main/noarch
  36. - https://repo.anaconda.com/pkgs/r/win-64
  37. - https://repo.anaconda.com/pkgs/r/noarch
  38. - https://repo.anaconda.com/pkgs/msys2/win-64
  39. - https://repo.anaconda.com/pkgs/msys2/noarch
  40. To search for alternate channels that may provide the conda package you're
  41. looking for, navigate to
  42. https://anaconda.org
  43. and use the search bar at the top of the page.
  44. (python27) C:\Users\DELL>
  45. C:\Users\DELL>conda search drf_yasg
  46. Loading channels: done
  47. No match found for: drf_yasg. Search: *drf_yasg*
  48. PackagesNotFoundError: The following packages are not available from current channels:
  49. - drf_yasg
  50. Current channels:
  51. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-64
  52. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  53. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  54. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  55. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  56. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  57. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  58. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  59. - https://repo.anaconda.com/pkgs/main/win-64
  60. - https://repo.anaconda.com/pkgs/main/noarch
  61. - https://repo.anaconda.com/pkgs/r/win-64
  62. - https://repo.anaconda.com/pkgs/r/noarch
  63. - https://repo.anaconda.com/pkgs/msys2/win-64
  64. - https://repo.anaconda.com/pkgs/msys2/noarch
  65. To search for alternate channels that may provide the conda package you're
  66. looking for, navigate to
  67. https://anaconda.org
  68. and use the search bar at the top of the page.
  69. C:\Users\DELL>conda search drf-yasg
  70. Loading channels: done
  71. # Name Version Build Channel
  72. drf-yasg 1.17.1 py_0 anaconda/cloud/conda-forge
  73. drf-yasg 1.20.0 py_0 anaconda/cloud/conda-forge
  74. C:\Users\DELL>conda activate python27
  75. (python27) C:\Users\DELL>conda install drf-yasg
  76. Collecting package metadata (current_repodata.json): done
  77. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  78. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
  79. Collecting package metadata (repodata.json): done
  80. Solving environment: done
  81. ## Package Plan ##
  82. environment location: D:\devTools\Python\Miniconda3\envs\python27
  83. added / updated specs:
  84. - drf-yasg
  85. The following packages will be downloaded:
  86. package | build
  87. ---------------------------|-----------------
  88. certifi-2019.11.28 | py27h8c360ce_1 149 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  89. coreapi-2.3.3 | pyh9f0ad1d_0 23 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  90. coreschema-0.0.4 | pyh9f0ad1d_0 15 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  91. djangorestframework-3.9.4 | py_0 756 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  92. drf-yasg-1.20.0 | py_0 1.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  93. inflection-0.5.1 | pyh9f0ad1d_0 9 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  94. itypes-1.2.0 | pyh9f0ad1d_0 7 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  95. jinja2-2.11.3 | pyh44b312d_0 93 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  96. markupsafe-1.1.1 | py27h462b5f4_1 26 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  97. packaging-20.9 | pyh44b312d_0 35 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  98. pyparsing-2.4.7 | pyh9f0ad1d_0 60 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  99. requests-2.13.0 | py27_0 780 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  100. ruamel-1.0 | py27h8c360ce_2 4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  101. ruamel.ordereddict-0.4.14 | py27h0c8e037_0 35 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  102. ruamel.yaml-0.16.6 | py27h462b5f4_1 165 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  103. ruamel.yaml.clib-0.2.0 | py27h462b5f4_1 115 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  104. simplejson-3.17.0 | py27h462b5f4_1 100 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  105. six-1.16.0 | pyh6c4a22f_0 14 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  106. uritemplate-3.0.1 | py_0 16 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  107. ------------------------------------------------------------
  108. Total: 3.6 MB
  109. The following NEW packages will be INSTALLED:
  110. coreapi anaconda/cloud/conda-forge/noarch::coreapi-2.3.3-pyh9f0ad1d_0
  111. coreschema anaconda/cloud/conda-forge/noarch::coreschema-0.0.4-pyh9f0ad1d_0
  112. drf-yasg anaconda/cloud/conda-forge/noarch::drf-yasg-1.20.0-py_0
  113. inflection anaconda/cloud/conda-forge/noarch::inflection-0.5.1-pyh9f0ad1d_0
  114. itypes anaconda/cloud/conda-forge/noarch::itypes-1.2.0-pyh9f0ad1d_0
  115. jinja2 anaconda/cloud/conda-forge/noarch::jinja2-2.11.3-pyh44b312d_0
  116. markupsafe anaconda/cloud/conda-forge/win-64::markupsafe-1.1.1-py27h462b5f4_1
  117. packaging anaconda/cloud/conda-forge/noarch::packaging-20.9-pyh44b312d_0
  118. pyparsing anaconda/cloud/conda-forge/noarch::pyparsing-2.4.7-pyh9f0ad1d_0
  119. requests anaconda/cloud/conda-forge/win-64::requests-2.13.0-py27_0
  120. ruamel anaconda/cloud/conda-forge/win-64::ruamel-1.0-py27h8c360ce_2
  121. ruamel.ordereddict anaconda/cloud/conda-forge/win-64::ruamel.ordereddict-0.4.14-py27h0c8e037_0
  122. ruamel.yaml anaconda/cloud/conda-forge/win-64::ruamel.yaml-0.16.6-py27h462b5f4_1
  123. ruamel.yaml.clib anaconda/cloud/conda-forge/win-64::ruamel.yaml.clib-0.2.0-py27h462b5f4_1
  124. simplejson anaconda/cloud/conda-forge/win-64::simplejson-3.17.0-py27h462b5f4_1
  125. six anaconda/cloud/conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
  126. uritemplate anaconda/cloud/conda-forge/noarch::uritemplate-3.0.1-py_0
  127. The following packages will be UPDATED:
  128. djangorestframewo~ anaconda/cloud/conda-forge/win-64::dj~ --> anaconda/cloud/conda-forge/noarch::djangorestframework-3.9.4-py_0
  129. The following packages will be SUPERSEDED by a higher-priority channel:
  130. done
  131. (python27) C:\Users\DELL>

conda deaactivate 退出环境

conda deactivate

  1. (python27) C:\Users\DELL>conda deactivate
  2. C:\Users\DELL>

退出后,前面的env名称消失

其它命令

参考: https://zhuanlan.zhihu.com/p/44398592

  1. # 安装package
  2. conda install -n py35 numpy
  3. # 如果不用-n指定环境名称,则被安装在当前活跃环境
  4. # 也可以通过-c指定通过某个channel安装
  1. C:\Users\DELL>conda list --help
  2. usage: conda-script.py list [-h] [-n ENVIRONMENT | -p PATH] [--json] [-v] [-q] [--show-channel-urls] [-c] [-f] [--explicit] [--md5] [-e] [-r]
  3. [--no-pip]
  4. [regex]
  5. List linked packages in a conda environment.
  6. Options:
  7. positional arguments:
  8. regex List only packages matching this regular expression.
  9. optional arguments:
  10. -h, --help Show this help message and exit.
  11. --show-channel-urls Show channel urls. Overrides the value given by `conda config --show show_channel_urls`.
  12. -c, --canonical Output canonical names of packages only. Implies --no-pip.
  13. -f, --full-name Only search for full names, i.e., ^<regex>$.
  14. --explicit List explicitly all installed conda packaged with URL (output may be used by conda create --file).
  15. --md5 Add MD5 hashsum when using --explicit
  16. -e, --export Output requirement string only (output may be used by conda create --file).
  17. -r, --revisions List the revision history and exit.
  18. --no-pip Do not include pip-only installed packages.
  19. Target Environment Specification:
  20. -n ENVIRONMENT, --name ENVIRONMENT
  21. Name of environment.
  22. -p PATH, --prefix PATH
  23. Full path to environment location (i.e. prefix).
  24. Output, Prompt, and Flow Control Options:
  25. --json Report all output as json. Suitable for using conda programmatically.
  26. -v, --verbose Use once for info, twice for debug, three times for trace.
  27. -q, --quiet Do not display progress bar.
  28. Examples:
  29. List all packages in the current environment::
  30. conda list
  31. List all packages installed into the environment 'myenv'::
  32. conda list -n myenv
  33. Save packages for future use::
  34. conda list --export > package-list.txt
  35. Reinstall packages from an export file::
  36. conda create -n myenv --file package-list.txt
  37. C:\Users\DELL>conda list --name python36 # 查看python36环境安装的package
  38. # packages in environment at D:\devTools\Python\Miniconda3\envs\python36:
  39. #
  40. # Name Version Build Channel
  41. certifi 2020.6.20 pyhd3eb1b0_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  42. pip 20.0.2 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  43. python 3.6.15 h39d44d4_0_cpython https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  44. python_abi 3.6 2_cp36m https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  45. setuptools 49.6.0 py36ha15d459_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  46. ucrt 10.0.20348.0 h57928b3_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  47. vc 14.2 hb210afc_6 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  48. vs2015_runtime 14.29.30037 h902a5da_6 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  49. wheel 0.37.1 pyhd8ed1ab_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  50. wincertstore 0.2 py36ha15d459_1006 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  51. C:\Users\DELL>

conda 使用不同的bit python

切换 win-32:set CONDA_FORCE_32BIT=1

在 cmd 运行 set CONDA_FORCE_32BIT=1 ,标识当前为 32 位的环境

  1. Microsoft Windows [版本 10.0.18363.1556]
  2. (c) 2019 Microsoft Corporation。保留所有权利。
  3. ## 查看环境,其中 platform 现在是 win-64
  4. C:\Users\DELL>conda info
  5. active environment : None
  6. user config file : C:\Users\DELL\.condarc
  7. populated config files : C:\Users\DELL\.condarc
  8. conda version : 4.11.0
  9. conda-build version : not installed
  10. python version : 3.9.7.final.0
  11. virtual packages : __win=0=0
  12. __archspec=1=x86_64
  13. base environment : D:\devTools\Python\Miniconda3 (writable)
  14. conda av data dir : D:\devTools\Python\Miniconda3\etc\conda
  15. conda av metadata url : None
  16. channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-64
  17. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  18. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  19. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  20. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  21. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  22. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  23. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  24. https://repo.anaconda.com/pkgs/main/win-64
  25. https://repo.anaconda.com/pkgs/main/noarch
  26. https://repo.anaconda.com/pkgs/r/win-64
  27. https://repo.anaconda.com/pkgs/r/noarch
  28. https://repo.anaconda.com/pkgs/msys2/win-64
  29. https://repo.anaconda.com/pkgs/msys2/noarch
  30. package cache : D:\devTools\Python\Miniconda3\pkgs
  31. C:\Users\DELL\.conda\pkgs
  32. C:\Users\DELL\AppData\Local\conda\conda\pkgs
  33. envs directories : D:\devTools\Python\Miniconda3\envs
  34. C:\Users\DELL\.conda\envs
  35. C:\Users\DELL\AppData\Local\conda\conda\envs
  36. platform : win-64
  37. user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.7 Windows/10 Windows/10.0.18363
  38. administrator : False
  39. netrc file : None
  40. offline mode : False
  41. ## 设置为32 位
  42. C:\Users\DELL>set CONDA_FORCE_32BIT=1
  43. ## 再次查看,现在 platform 就是 win-32, 就可以正常安装需要的 32 位的 python 了
  44. C:\Users\DELL>conda info
  45. active environment : None
  46. user config file : C:\Users\DELL\.condarc
  47. populated config files : C:\Users\DELL\.condarc
  48. conda version : 4.11.0
  49. conda-build version : not installed
  50. python version : 3.9.7.final.0
  51. virtual packages : __win=0=0
  52. __archspec=1=x86
  53. base environment : D:\devTools\Python\Miniconda3 (writable)
  54. conda av data dir : D:\devTools\Python\Miniconda3\etc\conda
  55. conda av metadata url : None
  56. channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-32
  57. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  58. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-32
  59. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  60. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-32
  61. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  62. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-32
  63. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  64. https://repo.anaconda.com/pkgs/main/win-32
  65. https://repo.anaconda.com/pkgs/main/noarch
  66. https://repo.anaconda.com/pkgs/r/win-32
  67. https://repo.anaconda.com/pkgs/r/noarch
  68. https://repo.anaconda.com/pkgs/msys2/win-32
  69. https://repo.anaconda.com/pkgs/msys2/noarch
  70. package cache : D:\devTools\Python\Miniconda3\pkgs32
  71. C:\Users\DELL\.conda\pkgs32
  72. C:\Users\DELL\AppData\Local\conda\conda\pkgs32
  73. envs directories : D:\devTools\Python\Miniconda3\envs
  74. C:\Users\DELL\.conda\envs
  75. C:\Users\DELL\AppData\Local\conda\conda\envs
  76. platform : win-32
  77. user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.7 Windows/10 Windows/10.0.18363
  78. administrator : False
  79. netrc file : None
  80. offline mode : False
  81. C:\Users\DELL>

切换 win-64:set CONDA_FORCE_32BIT=0

  1. C:\Users\DELL>conda info
  2. active environment : None
  3. user config file : C:\Users\DELL\.condarc
  4. populated config files : C:\Users\DELL\.condarc
  5. conda version : 4.11.0
  6. conda-build version : not installed
  7. python version : 3.9.7.final.0
  8. virtual packages : __win=0=0
  9. __archspec=1=x86
  10. base environment : D:\devTools\Python\Miniconda3 (writable)
  11. conda av data dir : D:\devTools\Python\Miniconda3\etc\conda
  12. conda av metadata url : None
  13. channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-32
  14. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  15. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-32
  16. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  17. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-32
  18. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  19. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-32
  20. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  21. https://repo.anaconda.com/pkgs/main/win-32
  22. https://repo.anaconda.com/pkgs/main/noarch
  23. https://repo.anaconda.com/pkgs/r/win-32
  24. https://repo.anaconda.com/pkgs/r/noarch
  25. https://repo.anaconda.com/pkgs/msys2/win-32
  26. https://repo.anaconda.com/pkgs/msys2/noarch
  27. package cache : D:\devTools\Python\Miniconda3\pkgs32
  28. C:\Users\DELL\.conda\pkgs32
  29. C:\Users\DELL\AppData\Local\conda\conda\pkgs32
  30. envs directories : D:\devTools\Python\Miniconda3\envs
  31. C:\Users\DELL\.conda\envs
  32. C:\Users\DELL\AppData\Local\conda\conda\envs
  33. platform : win-32
  34. user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.7 Windows/10 Windows/10.0.18363
  35. administrator : False
  36. netrc file : None
  37. offline mode : False
  38. ## 切换回到 win-64
  39. C:\Users\DELL>set CONDA_FORCE_32BIT=0
  40. C:\Users\DELL>
  41. C:\Users\DELL>
  42. C:\Users\DELL>conda info
  43. active environment : None
  44. user config file : C:\Users\DELL\.condarc
  45. populated config files : C:\Users\DELL\.condarc
  46. conda version : 4.11.0
  47. conda-build version : not installed
  48. python version : 3.9.7.final.0
  49. virtual packages : __win=0=0
  50. __archspec=1=x86_64
  51. base environment : D:\devTools\Python\Miniconda3 (writable)
  52. conda av data dir : D:\devTools\Python\Miniconda3\etc\conda
  53. conda av metadata url : None
  54. channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-64
  55. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
  56. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  57. https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  58. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  59. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  60. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  61. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
  62. https://repo.anaconda.com/pkgs/main/win-64
  63. https://repo.anaconda.com/pkgs/main/noarch
  64. https://repo.anaconda.com/pkgs/r/win-64
  65. https://repo.anaconda.com/pkgs/r/noarch
  66. https://repo.anaconda.com/pkgs/msys2/win-64
  67. https://repo.anaconda.com/pkgs/msys2/noarch
  68. package cache : D:\devTools\Python\Miniconda3\pkgs
  69. C:\Users\DELL\.conda\pkgs
  70. C:\Users\DELL\AppData\Local\conda\conda\pkgs
  71. envs directories : D:\devTools\Python\Miniconda3\envs
  72. C:\Users\DELL\.conda\envs
  73. C:\Users\DELL\AppData\Local\conda\conda\envs
  74. platform : win-64
  75. user-agent : conda/4.11.0 requests/2.27.1 CPython/3.9.7 Windows/10 Windows/10.0.18363
  76. administrator : False
  77. netrc file : None
  78. offline mode : False
  79. C:\Users\DELL>