Anaconda learning record

preface

Due to deep learning, python in Anaconda environment is used. But I don't know what anaconda is, why we use it, its benefits and what it can bring to us. Because the foundation is too poor, I often encounter difficulties in learning, and finally find out how much the impact of the lack of my foundation is. This article is used to record Anaconda's learning. [thanks to the author of this article]( https://www.jianshu.com/p/62f155eb6ac5)

1, What is Anaconda?

Anaconda is a hairstyle version that can obtain packages and management packages and manage the environment uniformly.

There are conda and 1000 + Science Libraries in Anaconda (if you don't need 1000 + science libraries, you can download miniAnaconda).

conda is a tool that can manage packages, their dependencies and environments.
conda was built for python, but currently supports multiple languages.

2, Use steps

1. Management environment

The command line is as follows. For Windows users, open Anaconda Prompt:

1. Create the environment, or create it through pycharm through the graphical interface

conda create --name <env_name> <package_names>

2. Switch environment

activate <env_name>

3. Exit the environment to root

decativate

4. Display the created environment

conda info --envs
conda info -e 
conda envs list

5. Replication environment

conda create --name <new_env_name> --clone <copied_env_name>

6. Delete environment

conda remove --name <env_name> --all

2. Management Pack

  1. Find package versions available for installation
    ① Exact search
		conda search --full-name <package_full_name>
		be careful:
		
		--full-name Parameters for exact lookup.
		
		<package_full_name>Is the full name of the package being searched. No angle brackets around the package name“<>". 
		
		For example: conda search --full-name python That is, find the full name“ python"What versions of the package are available for installation.

② Fuzzy search

			conda search <text>
	be careful:<text>Is to find the package name that contains this field. This field is not surrounded by angle brackets“<>". 
	
	For example: conda search py That is, find the information containing“ py"Field, which versions are available for installation.
  1. Get the installed package information in the current environment
    conda list
    After executing the above command, the package name and version number of the installed package in the current environment will be displayed on the terminal.

  2. Installation package
    ① Install the package in the specified environment
    conda install --name <env_name> <package_name>
    be careful:

    < env_name > the specified environment name of the package to be installed. The environment name is not surrounded by angle brackets "< >".

    < package_name > is the name of the package to be installed. There are no angle brackets "< >" around the package name.

    For example: conda install --name python2 pandas installs the pandas package in an environment named "python2".

② Install package in current environment

conda install <package_name>
be careful:

<package_name>The name of the package to be installed. There are no angle brackets around the package name“<>". 

After executing the command, install the package in the current environment.

For example: conda install pandas That is, install in the current environment pandas Bag.

③ Installing packages using pip
→ usage scenario
When conda install cannot be used for installation, pip can be used for installation. For example, see package.

→ command

pip install <package_name>
be careful:<package_name>Specifies the name of the installation package for. Package names are not enclosed in angle brackets“<>". 

For example: pip install see Namely installation see Bag.

→ note
Pip is only a package manager and cannot manage the environment. Therefore, if you want to use pip to install packages in the specified environment, you need to switch to the specified environment first, and then use the PIP command to install packages.

pip cannot update python because pip does not treat python as a package.

pip can install some packages that conda cannot install; conda can also install some packages that pip cannot install. Therefore, when you cannot install a package with one command, you can try another command.

④ Install the package from Anaconda.org
→ usage scenario
When conda install cannot be used for installation, you can consider obtaining the command of the installation package from Anaconda.org and installing it.

→ note
When installing packages from Anaconda.org, you do not need to register.

When installing a package from Anaconda.org in the current environment, you need to enter the path of the package to be installed in Anaconda.org as the channel. The way to query the path is as follows:

Enter in the browser:[ http://anaconda.org ], or click Anaconda.org directly

Enter the name of the package to be installed in the search box above "Anaconda Cloud" on the new page, and then click the "magnifying glass" sign on the right.

There are thousands of packages to choose from in the search results. At this time, click "Downloads" to sort according to the number of Downloads, and the package with the most Downloads is at the top.

Select the package that meets the requirements or the package with the most downloads, and click the package name.

Copy the command under "To install this package with conda run:" and paste it in the terminal for execution.

Complete the installation.

  1. Uninstall package
    ① Uninstall packages in the specified environment
conda remove --name <env_name> <package_name>
be careful:

<env_name>That is, the name of the specified environment where the uninstall package is located. The environment name is not surrounded by angle brackets“<>". 

<package_name>That is, the name of the package to be unloaded. There are no angle brackets around the package name“<>". 

For example: conda remove --name python2 pandas That is, the uninstall name is“ python2"Medium pandas Bag.

② Uninstall packages in the current environment

conda remove <package_name>
be careful:

<package_name>That is, the name of the package to be unloaded. There are no angle brackets around the package name“<>". 

After the command is executed, the specified package is unloaded in the current environment.

For example: conda remove pandas That is, uninstall in the current environment pandas Bag.
  1. Update package
    ① Update all packages
conda update --all
 or
conda upgrade --all

Suggestion: after installing anaconda, execute the above command to update all packages in Anaconda to the latest version for ease of use.
② Update specified package

conda update <package_name>
or
conda upgrade <package_name>

be careful:
< package_name > is the package name of the specified update. There are no angle brackets "< >" around the package name.

When updating multiple specified packages, the package names are separated by spaces and arranged backward. For example, conda update pandas numpy matplotlib updates pandas, numpy and matplotlib packages.

The author of this part is Raxxie
Link: https://www.jianshu.com/p/62f155eb6ac5

summary

Learning records

Tags: Python Pycharm Deep Learning

Posted on Tue, 16 Nov 2021 03:00:03 -0500 by Chrysanthus