python2+python3--Multi-version launch and multi-version PIP install issues

Source: Internet
Author: User

Background Description:

Python2 versions are aware that maintenance until 2020, the current use of Python a large part of the user community has started to install and use the latest version of the Python3 version, Python2 and Python3 in the programming of the large level has not changed, some changes in the details, Many people before the project is written with Python2, so two sets of environmental analysis source for many people to say, this essay records python2 and Python3 compatibility issues;

Preparation tools:

python-3.6.5 installation package, (previously there is a python2.7 environment, do not do too much name here;)

Specific operation:

One, Custom installation python3.6.5:

    

Tick add Python 3.6 to path means the environment variable is automatically added when installing-(pro-test: Only when the default installation check will take effect, automatically add environment variables, manual configuration of Python environment variable is actually very simple);

Check customize installation can be customized installation, including installation path, etc.;

    

Select the installation components and modules here;

    

If there is more than one user on the computer, please check the install for all users installation;

Customize Install location custom installation path;

Click the Install button and it will be installed;

    

After successful installation, check environment variables and modify relevant startup files before running;

Second, environment variables and file modification:

A. Open environment variable Check to add environment variables:

    

B. Modify the environment variables in the Add path variable;

    

cannot be truncated, but ensure that the environment variable contains the following path:

1.c:\python27--Install python2 boot path;

2.c:\python27\scripts--Install python2 when the PIP and other related boot path;

3.C:\PYTHON36-32--The boot path of the installation Python3;

4.c:\python36-32\scripts--Install python2 when the PIP and other related boot path;

Save environment changes after adding environment change exit;

CoreCoexistence Mode Method one: (not recommended)

C, modify the startup file as follows:

    

Here I only modified the Python3 boot file, because I will default to use Python2 programming, of course, you can also follow this method to modify the Python2 startup file is also possible;

D, to modify the pip file, the PIP installation time to distinguish between packages installed in Python version convenient for you to call the time without error;

Modified: C:\Python36-32\Scripts directory under the Pip.exe renamed to Pip3.exe can be;

    

Third, cmd in the corresponding check the final launch version;

1. Default python2.7:

    

2, Pthon3 start Python3:

    

Core Coexistence Method II: (Recommended)

Third, this method does not modify the Python installation of any file, the specific file is as follows:

The PYTHON3 environment variable file is as follows:

    

Start the corresponding version of Python in the following way:

    

    

The Python installation will install the core boot Py.exe on the computer, which can be identified by passing parameters and corresponding to the Python version on the computer.

And this problem greatly solves the problem of PIP Installa installation time;

Specific as follows:

Under Python3, Pip installs the Django command as follows:

    

After the installation is complete, go to site-packages check below:

    

Successful installation, perfect solution to Python startup and version PIIP issues;

Python2 the PIP installation command as follows:

Py-2-m pip install xxxxxx

Python3 the PIP installation command as follows:
Py-3-m pip install xxxxxx

python2+python3--Multi-version launch and multi-version PIP install issues

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.