6. Coexistence of Windows Anaconda2 (Python2) and Anaconda3 (Python3)

Source: Internet
Author: User
Tags virtual environment jupyter notebook

Preface

Anaconda is a python scientific computing release that contains more than 300 popular Python Packages for science, math, engineering, and data analysis. Since Python has 2 and 32 versions, Anaconda also launched two distributions, Anaconda2 and Anaconda3, based on Python2 and Python3.

Sometimes we use the Anaconda2 and Anaconda3 two versions on a computer, so it's important to consider their coexistence. The general use of the scene is based on one of the main version, another version supplemented, so only to achieve a convenient switch to the standby version, and the backup version of the PIP and other commands can be used normally.

Because Anaconda2 and Anaconda3 contain more modules, many people do not need these, so if you only want more pure Python2 and Python3 coexistence, you can see the last part of this article.

Operation Steps
    1. First install the main version , here we choose Anaconda2, follow the normal steps to install, it is assumed that the installation directory D:\Anaconda2 .

2. Make the two hooks at this step.

The first option is to add the installation directory to the system's Path environment variable, which you can use in cmd to start Python directly from the python command.
The second option is for other Ides to detect Anaconda2 and use Anaconda2 as the default Python 2.7.

3. After installing the ANACONDA2, then install ANACONDA3, here Anaconda3 installation directory must be selected in the D:\Anaconda2\envs subdirectory, the last "Py3" can be taken by themselves.

4. Remove the two hooks here (in the literal sense, the second tick should have no effect.) As for the first option, since the ANACONDA2 has been added to the system path path, so add the Anaconda3, because the order in the back of the Anaconda2, almost no effect, so there is no hook on it.

5. After the installation is complete, the direct input in cmd python will start the Python2, and use the activate py3 py3 (that is, the name of the previous Python3 installation directory folder) command, then use python You can switch to Python3as shown in. After using the activate py3 command, a flag appears at the front of the command line [py3] , python where any command is used under Python3 . Use the deactivate command to deactivate Python3.

Summary

The coexistence implementation of this article is based on Conda 's ability to create a virtual environment, as detailed in this link.

Therefore, after installing the major version first, you can also use the conda create -n py3 python=3 command to install Python3, but because of network problems, this method is easy to fail, so you first download the full installation package, and then install to the main version of the main directory envs folder more convenient.

One might say that you install Anaconda2 and Anaconda3directly at the same time, and then change the Python.exe in the Anaconda3 directory to Python3.exe can also achieve similar coexistence. But there is a big drawback to this approach, which is that some of the Ides contained within Anaconda3 will not work properly, such as Jupyter Notebook and Spyder , because they depend on the installation directory Python.exe, and the backup version of the pip command is also not able to directly use, overall very inconvenient.

6. Coexistence of Windows Anaconda2 (Python2) and Anaconda3 (Python3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.