Anaconda multi-Environment multi-version python configuration operation method, anacondapython
Conda test Guide
Before starting this conda test, you should have downloaded and installed Anaconda or Miniconda.
Note: After installation, you should close and re-open the windows command line.
I. Conda test process:
Use conda. First, we will confirm that you have installed conda.
Configure the environment. In the next step, we will create several environments to demonstrate the environment management functions of conda. It makes it easier for you to understand everything about the environment. We will learn how to confirm which environment you are in and how to copy an environment as a backup.
Test python. Then we will check which version of python can be installed, and install another version of python, and switch between the two versions of python.
Check the package. We will 1) list the packages installed on our computer, 2) Browse available packages, 3) use the conda install command to install and remove some packages. For some packages that cannot be installed using conda, we will search for them on the Anaconda.org website. For those packages in other locations, we will 5) use the pip command for installation. We will also install a commercial package IOPro that can be used for free for 30 days.
Remove package, environment, and conda. We will end this test by learning to delete your package, environment, and conda.
Ii. Complete process
Tip: at any time, you can keep up with -- help after the command to obtain the complete documentation of the command. For example, you can use the following command to learn the conda update command.
Conda update -- help
1. Manage conda:
Conda is both a package manager and an environment manager. You must know the Package Manager, which can help you discover and view packages. However, if we want to install a package, but this package only supports different versions than the python version we currently use. You only need several lines of commands to build an environment that can run another python version ., This is the powerful function of conda Environment Manager.
Tip: Whether you use Linux, OS X, or Windows command line tools, the conda commands on your command line terminal are the same unless otherwise specified.
Check that conda has been installed.
To ensure that you have installed conda in the correct position, let's check whether you have installed Anaconda successfully. In your command line terminal window, enter the following code:
Conda -- version
Conda returns the version of the Anaconda software you have installed.
Tip: If you see the error message, check whether you have selected to install only for the current user during the installation process and whether to operate with the same account. Make sure that you have logged on and installed it with the same account, and then re-open the command line terminal window.
Upgrade the current version of conda.
Next, run the following update command to upgrade conda:
Conda update conda
Conda will compare the old and new versions and tell you which version of conda can be installed. It will also notify you of the simultaneous upgrade of other packages with this upgrade.
If the new version of conda is available, it will prompt you to enter y for upgrade.
Proceed ([y]/n )? Y
After conda is updated to the latest version, we will enter the next topic.
2. management environment.
Now we create some environments to demonstrate the environment operations of conda, and then move them.
Create and activate an environment
Use the conda create Command, followed by any name you want to call it:
Conda create -- name snowflake biopython
This command will create a new environment for the biopython package at/envs/snowflakes
TIPS: A lot of common command options behind -- can be omitted as a short-term plus the first letter of the command. Therefore, the -- name option and-n have the same effect. You can use conda-h or conda -- help to view a large number of abbreviations.
Activate this new environment
Linux, OS X: source activate snowflakes
Windows: activate snowflake'
TIPS: the new development environment will be installed in the envs file directory under your conda directory by default. You can specify another path. Learn more through conda create-h.
TIPS: if we do not specify the python version, donda will install the python version we installed when we first installed conda.
Create the second Environment
This time, let's create and name a new environment, and then install python of another version and two packages, Astroid and Babel.
Conda create-n bunnies python = 3 Astroid Babel
This will create the second Environment Based on python3, including the Astroid and Babel package, called bunnies, In the/envs/bunnies folder.
TIPS: Install the package you want to run in this environment at the same time,
TIPS: Install all the packages you want while creating the environment. Subsequent installation may cause dependency problems (it seems like you don't know how to use this term ).
Tip: You can append multiple conditions behind the conda create command and type conda create-h to view more details.
List all environments
Now let's check the environment you have installed so far, and run the conda environment info command to view it:
Conda info -- envs
You will see the following Environment list:
Conda environments:
Snowflakes */home/username/miniconda/envs/snowflakes
Bunnies/home/username/miniconda/envs/bunnies
Root/home/username/miniconda
Confirm current environment
In which environment are you in? Snowflakes or bunnies? To determine it, enter the following code:
Conda info-envis
Conda will display a list Of all environments, and the current environment will be displayed in a bracket.
(Snowflakes)
Note: conda sometimes adds the * sign before the current active environment.
Switch to another environment (activate/deactivate)
To switch to another environment, type the following command and the name of the required environment.
Linux, OS X: source activate snowflakes
Windows: activate snowflakes
If you want to switch from the path of your current work environment to the system root directory, type:
Linux, OS X: source deactivate
Windows: deactivate
When the environment is no longer active, it will not be displayed in advance.
Copy an environment
Copy an environment by cloning it. Here we will create a copy called flowers by cloning snowfllakes.
Conda create-n flowers -- clone snowflakes
Check the environment through conda info -- envs
Now you can see a list of environments: flowers, bunnies, and snowflakes.
Delete an environment
If you do not want the flowers environment, remove it as follows:
Conda remove-n flowers -- all
To confirm that the Environment named flowers has been removed, enter the following command:
Conda info-e
Flowers is no longer in your environment list, so we know it is deleted.
Learning