Commands commonly used by conda: creation, switching environments, installation instructions for third-party libraries.

  1. After the conda installation is complete, I want to check whether I have installed conda successfully. I can open the cmd command by pressing window+R on the keyboard, as shown in the following figure:

After opening, enter on the command line: conda --version to view the version number of your currently installed Anconada, as shown in the figure below:

  1. Conda is used to create different virtual environments, which means that my current project may require python version 2.6, and my other project may require version 3.6, then I can create a virtual environment for each project , they do not affect each other.

Then how do I check which virtual environments I have created currently? Use the above window to enter: conda info --envs to view the virtual environment I am currently creating. As shown in the figure below, there is currently only one base, which is installed after you It already exists, as shown in the following figure:

  1. So how should I enter a certain virtual environment? Enter: conda activate base , which means that I want to activate the virtual environment named base. If you create a new virtual environment, just replace base with the name of the virtual environment you created. The information in parentheses in front indicates your current virtual environment, as shown in the following figure:

  1. So how do I create a new virtual environment? For example, I want to create a virtual environment named yolo, and the required python version is 3.7, then enter: conda create -n yolo python=3.7 , -n means name, then I will enter the project I want to create later The name, the yolo I specified here, can be customized, and the version of python can be set by yourself. Then wait for it to prompt you y/n. Enter y and wait for the virtual environment to be created. As shown below:

  1. 那我如何查看我的环境是否创建好了呢?前面第二步已经说明了,输入:conda info --envs,当前的虚拟环境就不止是base一个,还有我创建的yolo这个虚拟环境。如下图所示:

  1. 那我如何进入到新创建的虚拟环境?前面第三步已经说明了,输入:conda activate yolo,就能激活yolo这个虚拟环境。如下图所示:

  1. 那我如何查看我当前创建的虚拟环境中都有哪些包呢?输入:conda list,即可查看当前的虚拟环境中都包含哪些package。如下图所示:

  1. 那我如何在新创建好的虚拟环境中安装第三方库呢?比如我要安装numpy,则在需要安装的虚拟环境下输入:conda install numpy,在等待过程中,依然会提示y/n,输入y等待即可。如下图所示:

  1. 安装好之后,我们可以通过第七步说明的那样,输入:conda list,发现当前的列表里多出了我们安装的numpy,安装其他第三方库,同样可以按照这种方式来。如下图所示:

总结:按照我上面的思路,基本上conda常用的指令也就这些,从最开始的查看安装conda的版本,创建虚拟环境,切换虚拟环境,查看已有的虚拟环境,在当前虚拟环境安装第三方库,当前虚拟环境安装的第三方库列表。

书写不易,转载请注明出处。

Guess you like

Origin blog.csdn.net/BaoITcore/article/details/129633117