In Windows, the python 2.x interpreter and the 3.x interpreter coexist.

Source: Internet
Author: User

In Windows, the python 2.x interpreter and the 3.x interpreter coexist.

Python2 and Python3 are incompatible. If you encounter a situation where you cannot upgrade to Python2 code or your colleagues stick to the Python2 camp, you must consider the coexistence of Python2 and Python3 in the system.

Mac OS X and Linux do not have to consider this situation. Because these Unix-like operating systems will directly map to Python3 when installing Python3. Install Python 2 and Python 3 at the same time.

Here we will only discuss Windows. Below are my common methods.

1. Create a D: \ Python folder;

2. Install Python 2.7 to D: \ Python27 and install Python 3.4 to D: \ Python34. Do not add Python to the path environment variable during installation;

3. create d: \ Python \ py2.bat with the following content:

D: \ Python \ 27 \ python.exe % *

4. create d: \ Python \ py3.bat with the following content:

D: \ Python \ 34 \ python.exe % *

5. Add D: \ Python to the environment variable PATH.

After such processing, you can directly input

Py3 yourpythonfile. py arg1 arg2

And Python2.

Related Article

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.