Anaconda vs Miniconda:Python 环境管理
Anaconda vs MinicondaPython 环境管理1. 选择 Anaconda or Miniconda1.1. Anaconda or Miniconda?1.2. GUI versus command line installer1.3. Cryptographic hash verification2. Managing Python2.1. Viewing a list of available Python versions2.2. Installing a different version of Python2.3. Updating Python3. Managing packages3.1. Searching for packages3.2. Installing packages3.3. Installing non-conda packages3.4. Viewing a list of installed packages3.5. Updating packages3.6. Removing packagesReferencesCondahttps://conda.io/en/latest/index.htmlMinicondahttps://conda.io/en/latest/miniconda.htmlDownloading condahttps://docs.conda.io/projects/conda/en/latest/user-guide/install/download.htmlMiniconda 软件库https://repo.anaconda.com/miniconda/Commandshttps://docs.conda.io/projects/conda/en/latest/commands/index.html1. 选择 Anaconda or MinicondaYou have 3 conda download options:Download Anaconda - free.Download Miniconda - free.Purchase Anaconda Enterprise.You can download any of these 3 options with legacy Python 2.7 or current Python 3.If you are unsure which option to download, choose the most recent version of Anaconda3. If you are on Windows or macOS, choose the version with the GUI installer.purchase [pɜ:tʃəs]v. 购买获得赢得升起举起 n. 购买购买的东西支点财产置得地产的 年收益紧握起重装置 enterprise [ˈentəpraɪz]n. 企业事业进取心事业心 legacy [ˈleɡəsi]n. 遗赠遗产 Anaconda [ˌænəˈkɒndə]1.1. Anaconda or Miniconda?Choose Anaconda if you:Are new to conda or Python.Like the convenience of having Python and over 1,500 scientific packages automatically installed at once.Have the time and disk space - a few minutes and 3 GB.Do not want to individually install each of the packages you want to use.Wish to use a set of packages curated and vetted for interoperability and usability.individually [ˌɪndɪˈvɪdʒuəli]adv. 个别地单独地Choose Miniconda if you:Do not mind installing each of the packages you want to use individually.Do not have time or disk space to install over 1,500 packages at once.Want fast access to Python and the conda commands and you wish to sort out the other programs later.Anaconda 是包含常用包的版本Miniconda 是精简版推荐使用 Miniconda。1.2. GUI versus command line installerBoth GUI and command line installers are available for Windows, macOS, and Linux:If you do not wish to enter commands in a terminal window, choose the GUI installer.If GUIs slow you down, choose the command line version.1.3. Cryptographic hash verificationSHA-256 checksums are available for Miniconda and Anaconda.We do not recommend using MD5 verification as SHA-256 is more secure.Download the installer file and before installing verify it as follows:Windows:If you have PowerShell V4 or later: Open a PowerShell console and verify the file as follows:Get-FileHash filename -Algorithm SHA256If you don’t have PowerShell V4 or later: Use the free online verifier tool on the Microsoft website.Download the file and extract it.Open a Command Prompt window.Navigate to the file.Run the following command:Start-PsFCIV -Path C:pathtofile.ext -HashAlgorithm SHA256 -OnlinemacOS:In iTerm or a terminal window entershasum -a 256 filename.Linux:In a terminal window entersha256sum filename.(base) yongqiangyongqiang:~/software$ sha256sum platform-tools_r37.0.0-win.zip 4fe305812db074cea32903a489d061eb4454cbc90a49e8fea677f4b7af764918 platform-tools_r37.0.0-win.zip (base) yongqiangyongqiang:~/software$cryptographic [,krɪptəgræfɪk]adj. 关于暗号的用密码写的2. Managing Pythonhttps://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-python.htmlConda treats Python the same as any other package, so it is easy to manage and update multiple installations.Conda supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.2.1. Viewing a list of available Python versionsTo list the versions of Python that are available to install, in your terminal window, run:(base) yongqiangyongqiang:~$ conda search python Loading channels: done # Name Version Build Channel python 2.7.13 hac47a24_15 anaconda/pkgs/main python 2.7.13 heccc3f1_16 anaconda/pkgs/main python 2.7.13 hfff3488_13 anaconda/pkgs/main ... python 3.14.4 h490e9c7_100_cp314 anaconda/pkgs/main python 3.14.4 h9109617_0_cp314t anaconda/pkgs/main python 3.14.5 h1927d3b_0_cp314t anaconda/pkgs/main python 3.14.5 h4bdf6f9_100_cp314 anaconda/pkgs/main python 3.14.6 h1927d3b_0_cp314t anaconda/pkgs/main python 3.14.6 h1927d3b_1_cp314t anaconda/pkgs/main python 3.14.6 h4bdf6f9_100_cp314 anaconda/pkgs/main python 3.14.6 h4bdf6f9_101_cp314 anaconda/pkgs/main (base) yongqiangyongqiang:~$This lists all packages whose names contain the textpython.To list only the packages whose full name is exactlypython, add the--full-nameoption. In your terminal window, run:(base) yongqiangyongqiang:~$ conda search --full-name python Loading channels: done # Name Version Build Channel python 2.7.13 hac47a24_15 anaconda/pkgs/main python 2.7.13 heccc3f1_16 anaconda/pkgs/main python 2.7.13 hfff3488_13 anaconda/pkgs/main python 2.7.14 h1571d57_29 anaconda/pkgs/main ... python 3.14.4 h490e9c7_100_cp314 anaconda/pkgs/main python 3.14.4 h9109617_0_cp314t anaconda/pkgs/main python 3.14.5 h1927d3b_0_cp314t anaconda/pkgs/main python 3.14.5 h4bdf6f9_100_cp314 anaconda/pkgs/main python 3.14.6 h1927d3b_0_cp314t anaconda/pkgs/main python 3.14.6 h1927d3b_1_cp314t anaconda/pkgs/main python 3.14.6 h4bdf6f9_100_cp314 anaconda/pkgs/main python 3.14.6 h4bdf6f9_101_cp314 anaconda/pkgs/main (base) yongqiangyongqiang:~$2.2. Installing a different version of PythonTo install a different version of Python without overwriting the current version, create a new environment and install the second Python version into it:Create the new environment:To create the new environment for Python 3.9, in your terminal window run:conda create -n py39 python3.9Replacepy39with the name of the environment you want to create.python3.9is the package and version you want to install in this new environment. This could be any package, such asnumpy1.19, or multiple packages.Activate the new environment.Verify that the new environment is your current environment.To verify that the current environment uses the new Python version, in your terminal window, run:python --version2.3. Updating PythonTo update Python to the latest version in your environment, run:conda update pythonThis command will update you to the latest major release (e.g. frompython3.10topython3.12).If you would like to remain on a minor release, use theconda installcommand instead:conda install python3.103. Managing packageshttps://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html3.1. Searching for packagesTo see if a specific package, such as SciPy, is available for installation:conda search scipyTo see if a specific package, such as SciPy, is available for installation from Anaconda.org:conda search --override-channels --channel defaults scipyTo see if a specific package, such as iminuit, exists in a specific channel, such as http://conda.anaconda.org/mutirri, and is available for installation:conda search --override-channels --channel http://conda.anaconda.org/mutirri iminuit3.2. Installing packagesTo install a specific package such as SciPy into an existing environment “myenv”:conda install --name myenv scipyIf you do not specify the environment name, which in this example is done by--name myenv, the package installs into the current environment:conda install scipyTo install a specific version of a package such as SciPy:conda install scipy0.15.0To install multiple packages at once, such as SciPy and cURL:conda install scipy curlIt is best to install all packages at once, so that all of the dependencies are installed at the same time.To install multiple packages at once and specify the version of the package:conda install scipy0.15.0 curl7.26.0To install a package for a specific Python version:conda install scipy0.15.0 curl7.26.0 -n py34_envIf you want to use a specific Python version, it is best to use an environment with that version.3.3. Installing non-conda packagesIf a package is not available from conda or Anaconda.org, you may be able to find and install the package via conda-forge or with another package manager likepip.Pip packages do not have all the features of conda packages and we recommend first trying to install any package with conda. If the package is unavailable through conda, try finding and installing it with conda-forge.If you still cannot install the package, you can try installing it withpip. The differences betweenpipand conda packages cause certain unavoidable limits in compatibility but conda works hard to be as compatible with pip as possible.如果仍然无法安装该软件包您可以尝试使用pip安装。pip和 conda 软件包之间的差异会导致一些不可避免的兼容性限制但 conda 会尽力使其与 pip 保持尽可能高的兼容性。Bothpipand conda are included in Anaconda and Miniconda, so you do not need to install them separately.Conda environments replace virtualenv, so there is no need to activate a virtualenv before using pip.It is possible to havepipinstalled outside a conda environment or inside a conda environment.pip可以安装在 conda 环境之外也可以安装在 conda 环境之内。To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment and then install packages with that instance ofpip. The commandconda listshows packages installed this way, with a label showing that they were installed withpip.要利用 conda 集成的优势请确保在当前激活的 conda 环境中安装pip然后使用该pip实例安装软件包。conda list命令会显示以这种方式安装的软件包并带有使用pip安装的标签。You can installpipin the current conda environment with the commandconda install pip.If there are instances ofpipinstalled both inside and outside the current conda environment, the instance ofpipinstalled inside the current conda environment is used.To install a non-conda package:Activate the environment where you want to put the program:In your terminal window, runconda activate myenv.To use pip to install a program such as See, in your terminal window, run:pip install seeTo verify the package was installed, in your terminal window, run:conda list3.4. Viewing a list of installed packagesTo list all of the packages in the active environment:conda listTo list all of the packages in a deactivated environment:conda list -n myenv3.5. Updating packagesUseconda updatecommand to check to see if a new update is available. If conda tells you an update is available, you can then choose whether or not to install it.To update a specific package:conda update biopythonTo update Python:conda update pythonTo update conda itself:conda update condaConda updates to the highest version in its series, so when updating Python, it updates to the highest available in the 3.x series.To update the Anaconda metapackage:conda update conda conda update anacondaRegardless of what package you are updating, conda compares versions and then reports what is available to install. If no updates are available, conda reports “All requested packages are already installed.”If a newer version of your package is available and you wish to update it, type y to update:Proceed ([y]/n)? y3.6. Removing packagesTo remove a package such as SciPy in an environment such as myenv:conda remove -n myenv scipyTo remove a package such as SciPy in the current environment:conda remove scipyTo remove multiple packages at once, such as SciPy and cURL:conda remove scipy curlTo confirm that a package has been removed:conda listReferences[1] Yongqiang Cheng (程永强), https://yongqiang.blog.csdn.net/[2] Anaconda vs MinicondaPython 环境管理, https://mp.weixin.qq.com/s/a4JC_fMLoXPktl0eyUpiNQ