Home  >  Article  >  Backend Development  >  What are the command operations related to conda and the environment in python?

What are the command operations related to conda and the environment in python?

WBOY
WBOYforward
2023-05-04 21:31:051317browse

1. Virtual environment

It is a virtualization concept, an environment developed independently from the computer. In layman's terms, a virtual environment uses a virtual machine to isolate part of the content. We call this independent part a "container". In this container, we can only install the dependency packages we need. They are isolated from each other and do not affect each other

2. The role of virtual environment

In some project development, we need the framework of some projects, but the framework used by each project may be different. Or the version of the framework used is different, which requires us to constantly update or uninstall the corresponding library according to needs. This will obviously be very troublesome and greatly reduce the efficiency of work. The virtual environment solves this problem very well. We can install different frameworks in different environments respectively. When necessary, we only need to switch environments.

3. What is conda

  • conda is an open source software package management system and environment management system, used to install multiple versions of software packages and their dependencies, and Easily switch between them, conda is just a tool, it has two distributions, namely Anaconda and Miniconda

  • Anaconda is a heavyweight one, with conda pre-installed in it , a certain version of python, many package calculation tools, etc., which take up a lot of space.

  • Miniconda is lightweight and contains basic conda and python. Some libraries need to be installed by yourself. It is relatively light and flexible and takes up little space

The following will be based on some environment-related instructions in Anaconda under Windows

4. Environment-related instructions

1. Check the package

After downloading Anaconda, Find the Anaconda file in the start menu, open it as follows and enter

What are the command operations related to conda and the environment in python?

Enter

conda list

to view the currently included packages

What are the command operations related to conda and the environment in python?

2. Check the conda version

conda --version

What are the command operations related to conda and the environment in python?

3. Check the environment

conda info -e

What are the command operations related to conda and the environment in python?

This is shown There are two environments, the first base is the default one, and the second one is an environment I created myself

4. Create a new environment

conda create -n tensorflow python=3.8

tensorflow is what you want to name this environment Name, followed by python is the version number

After entering the above command, press Enter. After waiting for a while, the following will appear, asking you whether to add these packages

What are the command operations related to conda and the environment in python?

Enter

y

After waiting for a period of time, the following appears, indicating that the installation is successful

What are the command operations related to conda and the environment in python?

Check the environment at this time, you can see

What are the command operations related to conda and the environment in python?

A new environment has been created so far

5. Environment switching

It is currently the base environment. For example, I want to enter the tensorflow environment I created. Enter the following command to enter the environment

conda activate tensorflow

What are the command operations related to conda and the environment in python?

6.Exit the environment

conda deactivate

What are the command operations related to conda and the environment in python?

7.Delete the environment

n is followed by the name of the environment you want to delete

conda remove -n tensorflow --all

What are the command operations related to conda and the environment in python?

yAfter confirmation

What are the command operations related to conda and the environment in python?

Okay It can be seen that this environment has been deleted

What are the command operations related to conda and the environment in python?

The above is the detailed content of What are the command operations related to conda and the environment in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete