Many Anaconda, many environmental version python configuration guide: www.jianshu.com/p/d2e15200e… \

The original blog is the official document translation, plus a portion of their content, the original official address: conda.pydata.org/docs/test-d…


Conda Test Guide

Before starting this Conda test, you should have downloaded and installed Anaconda or Miniconda. Note: After installing, you should close and reopen the Windows command line.

I. Conda Test process:

  1. Use conda. First we will make sure that you have conda installed
  2. Configure the environment. Next we will demonstrate conda’s environment management capabilities by creating several environments. Make it easier for you to understand everything about the environment. We will learn how to confirm which environment you are in and how to make a copy of an environment as a backup.
  3. Test the python. Then we’ll check which version of Python can be installed, install the other version, and switch between the two versions of Python.
  4. Check the package. We will 1) list the packages installed on our computer, 2) browse the available packages, and 3) use conda install to install and remove some packages. For some packages that cannot be installed using Conda, we will 4) search at Anaconda.org. For those packages in other locations, we will implement the installation using the PIP command. We’ll also install a 30-day free trial commercial package called IOPro
  5. Remove packages, environments, and conda. We’ll end this test by learning to delete your packages, environments, and Conda.

Second, the complete process

Tip: You can get the full documentation of a command at any time by following it with –help. For example, you can learn the conda update command by using the following command.

conda update --help
Copy the code

1. Manage Conda:

Conda is both a package manager and an environment manager. You certainly know the Package manager, which helps you find and view packages. But if we want to install a package that only supports a different version of Python than the one we’re currently using. With just a few lines of command, you can set up an environment that can run another version of Python. This is the power of conda environment manager. Tip: Whether you use a Linux, OS X, or Windows command line tool, the conda command on your command line terminal is the same unless otherwise specified.

Check that Conda is installed.

To make sure you’ve installed Conda in the right place, let’s check that you’ve successfully installed Anaconda. From your command line terminal window, type the following code:

conda --version
Copy the code

Conda will return you the version of Anaconda software you installed. Tip: If you see an error message, check to see if you have selected install only for the current user during setup and if you are using the same account. Be sure to log in to the installation using the same account and reopen the command-line terminal window.

Upgrade the current version of Conda

Next, let’s upgrade conda by using the following update command:

conda update conda
Copy the code

Conda will compare the old and new versions and tell you which version of Conda can be installed. It will also notify you of updates to other packages along with the upgrade. If a new version of Conda is available, it will prompt you to type Y to upgrade.

proceed ([y]/n)? y
Copy the code

After conda is updated to the latest version, we will move on to the next topic.

2. Manage the environment.

Now let’s show conda’s environment operations by creating some environments and then moving them around.

Create and activate an environment

Use the conda create command, followed by whatever name you wish to call it:

conda create --name snowflake biopython
Copy the code

This command will create a new environment for the biopython package at /envs/ Snowflakes tip: a number of common command options following — can be abbreviated as a dash plus command initial. So the –name option has the same effect as -n. See a number of abbreviations by conda -h or conda — help.

Activate the new environment

Linux, OS X: source activate Snowflakes Windows: Activate Snowflake 'Copy the code

Tip: the new development environment will be installed by default in the envs file in your conda directory. You can specify another path; Go to Conda create-h to learn more. Tip: If we do not specify the version of Python to install, Donda will install the same version of Python that we originally installed when conda was installed.

Create a second environment

This time let’s create and name a new environment, and then install another version of Python with the two packages Astroid and Babel.

conda create -n bunnies python=3 Astroid Babel
Copy the code

This will create a second python3-based new environment with Astroid and Babel packages called bunnies, in the /envs/bunnies folder. Tip: Install all the packages you want to run in the environment at the same time. Tip: Install all the packages you want to run in the environment at the same time you create the environment, and installing them later can cause dependency problems. Tip: You can add more conditions to the conda create command. Type conda create -h to see more details.

List all the environments

Now let’s examine the environment you have installed so far, using the conda environment info command to view it:

conda info --envs
Copy the code

You should see the following list of environments:

conda environments:

 snowflakes          * /home/username/miniconda/envs/snowflakes

 bunnies               /home/username/miniconda/envs/bunnies

 root                  /home/username/miniconda
Copy the code

Confirm the current environment

What environment are you in right now? Snowflakes or Bunnies? To determine this, type the following code:

conda info -envis
Copy the code

Conda will display a list of all environments, with the current environment displayed in parentheses.

(snowflakes)
Copy the code

Note: Conda also sometimes places an * in front of the current operating environment.

Switch to another environment (activate/deactivate)

To switch to another environment, type the following command along with the name of the desired environment.

Linux, OS X: Source Activate Snowflakes Windows: Activate SnowflakesCopy the code

To switch from your current working environment to the system root directory, type:

Linux, OS X: source deactivate Windows: deactivateCopy the code

When the environment is no longer active, it is no longer displayed in advance.

Copy an environment

To replicate an environment by cloning. Here we will clone Snowfllakes to create a replica called Flowers.

conda create -n flowers --clone snowflakes
Copy the code

Check environments with Conda Info — envs you should now see a list of environments: Flowers, Bunnies, and Snowflakes.

Deleting an environment

If you don’t want the environment named Flowers, remove it as follows:

conda remove -n flowers --all
Copy the code

To confirm that the environment named Flowers has been removed, type the following command:

conda info -e
Copy the code

Flowers is no longer in your environment list, so we know it’s been deleted.

Learn more about the environment

If you want to learn more about conda, follow -h after the command

conda remove -h
Copy the code

3. Management of Python

Conda manages Python similarly to other packages, making it easy to manage and upgrade multiple installations.

Checking the Python Version

First let’s check which version of Python can be installed:

conda search --full --name python
Copy the code

You can use conda search Python to see all packages with “python” in their names or add the –full –name command option to list packages that exactly match “Python”.

Install a different version of Python

Now let’s say you need PYTHon3 to compile the program, but you don’t want to override your PYTHon2.7 to upgrade, you can create and activate an environment called snakes, and install the latest version of Python3 using the following command:

conda create -n snakes python=3 ·Linux, OS X: Source Activate snakes ·Windows: Activate snakesCopy the code

Tip: Giving your environment a fancy name, such as “Python3”, is wise, but not fun.

The environment is successfully added

To ensure that the snakes environment is installed, type the following command:

conda info -e
Copy the code

Conda will display a list of environments, and the currently active environment will be enclosed in brackets.

Check the Python version in the new environment

Ensure python3 is running in the snakes environment:

python --version
Copy the code

Use different versions of Python

To use different versions of Python, you can switch the environment by simply activating it. Let’s see how to return to the default 2.7

·Linux, OS X: Activate Snowflakes ·Windows: Activate SnowflakesCopy the code

Check the Python version:

Make sure the Snowflakes environment is still running the same version of Python that you installed when you installed Conda.

python --version
Copy the code

Unregister the environment

When you’re done with your studio in a Snowflakes environment, unlog it and switch your path to the previous state:

·Linux, OS X: Source deactivateCopy the code

4. Management package

Now let’s demonstrate the package. We have installed some packages (Astroid, Babel, and some specific versions of Python) when we create a new environment. We check which packages we have installed, check what is available, look for the specific package and install it. Next we find and install some specified packages in the Anconda.org repository, use Conda to do more than PIP can do, and install a commercial package.

View a list of packages and their versions in this environment:

Use this command to see which versions of Python or other programs are installed in the environment, or to ensure that certain packages have been installed or removed. In your terminal window type:

conda list
Copy the code

Use the conda command to view the list of available packages

A list of available conda installation package, according to the classification of Python version, can be gained from this address: docs. Continuum. IO/anaconda/pk…

Finding a package

First let’s check if the package we need can be installed via Conda:

conda search beautifulsoup4
Copy the code

It shows the package, so we know it’s available.

Install a new package

We will install the Beautiful Soup package in our current environment using the conda command as follows; Conda install –name Bunnies beautifulsoup4 Tip: You must tell Conda the name of the environment you want to install (-n bunies) or it will be installed into the current environment. Now activate the Bunnies environment and use the Conda list to show which programs are installed.

·Linux, OS X: Activate Bunnies ·Windows: Activate BunniesCopy the code

Install a package from Anaconda.org

If a package cannot be installed using Conda, we will next look at Anaconda.org. Anaconda.org provides package management services to public and private package repositories. Anaconda.org is a continuous analysis product. Tip: You are not required to register to download at Anaconda.org. To download from Anaconda.org into the current environment, we need to specify Anaconda.org as a specific channel by entering the full path to the package. In a browser, go to anaconda.org. We are looking for a package called “bottleneck”, so enter “bottleneck” in the upper left corner of the Search box called “Search Anaconda Cloud” and click the Search button. Anaconda.org will have more than a dozen bottleneck pack versions available, but we wanted the one that was downloaded most frequently. So you can sort by Download, by clicking on the Download bar. Click on the package name to select the most frequently downloaded package. It links to the Anaconda.org details page to show the specific commands to download:

Conda install --channel https://conda.anaconda. ort/pandasCopy the code

Check for downloaded packages

conda list
Copy the code

Install packages through the PIP command

For packages that cannot be installed through Conda or obtained from Anaconda.org, PIP (short for “PIP Install Packages”) is usually used to install packages. Tip: PIP is just a package manager, so it can’t manage the environment for you. PIP can’t even upgrade Python because it doesn’t treat Python as a package like Conda does. But it can install packages that Conda cannot install, and vice Versa. PIP and Conda are integrated into Anaconda or Miniconda.

We activate the environment where we want to place the program, and then install a program called “See” through PIP.

·Linux, OS X: Source Activate Bunnies ·Windows: Activate Bunnies install PIP seeCopy the code

Checking PIP Installation

Check whether See is installed:

conda list
Copy the code

Installing commercial Packages

An exception occurred during the installation of commercial packages and your installation of other packages. As an example, let’s install and remove IOPro, a free trial of a newer commercial package, to speed up your Python processing:

conda install iopro
Copy the code

Tip: Except for academic use, this version expires after 30 days of probation

You can now install and check any package you want to install with Conda, whether using conda, downloading from Anaconda.org, or installing with PIP, whether open source or commercial.

5. Remove packages, environments, or Conda

If you like. Let’s conclude this test guide by removing one or more test packs, environments, and Conda.

Remove the package

Suppose you decide not to use the commercial package IOPro. You can remove it in bunnies.

conda remove -n bunnies iopro
Copy the code

Verify that the packet has been removed

Use the conda list command to confirm that the IOPro has been removed

conda list
Copy the code

Remove the environment

We don’t need a snakes environment anymore, so type the following command: conda remove -n snakes –all

Verify that the environment is removed

To verify that the snakes environment has been removed, type the following command:

 conda info --envis
Copy the code

Snakes no longer show up in the environment list, so we know that it has been removed

Delete conda

  • Linux, OS X: Remove the Anaconda or Miniconda installation folder
rm -rf ~/miniconda OR  rm -rf ~/anaconda
Copy the code
  • Windows: Go to the Control Panel, click “Add or Remove Programs”, select “Python2.7 (Anaconda)” or “Python2.7 (Miniconda)” and click “Remove programs”.

Author: NorthPenguin links: www.jianshu.com/p/d2e15200e… The copyright of the book belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.