Home  >  Article  >  Backend Development  >  Compatibility issues between python2 and 3 on Windows platform

Compatibility issues between python2 and 3 on Windows platform

大家讲道理
大家讲道理Original
2017-05-28 09:55:491472browse

Many friends have installedpython2 and 3, because some libraries such as scapy, not scrapy, and python3 are all wrong, so how to use python2 and 3 Coexist.

Like ordinary programmers, achieve the following results

  • Compatibility issues under Windows platform

  • CMD can enter the interactive mode of python2 and 3 respectively

  • CMD can normally use the python2 and 3 versions corresponding to pip

Please follow the steps

  1. Make sure to add the paths of python2 and 3 to the environmentVariables
    C:\Python27\ ;C:\Python27\Scripts\;C:\Python36\Scripts\;C:\Python36\Scripts\

  2. Name the python.exe in the corresponding file as python2 .exe/python3.exe, name the pip.exe in the corresponding Scripts as pip2/pip3.exe. At this timeRestart the system

  3. Open the command line interface, Enter python2/python3 and enter successfully! ! !

  4. The last step is to check pip
    pip
    pip2
    ...
    It will not work if you send it first , Alas, I was tricked by Baidu

  5. Reinstall python2/3, python3 may not be uninstalled, rapair it first and then uninstall it.

The above is the process of how I was cheated, cherish life and stay away from Baidu
The following is the correct answer

  • After installing python2/3, you will find that there is an additional *py.exe* program under the Windows file. This is the official correct solution.

  • From the command line, you can follow the following commands
    py -2 Enter the editing interface of python2
    py -3Similarly
    py -2 -m various commands of pippython2 runs pip
    py -3 -m various commands of pipSimilar to the various commands
    py -2 -m one<a href="http://www.php.cn/wiki/1313.html" target="_blank">file</a>.pyRun onefile.py with python2
    py -3 -m onefile.py Same thing

I suggest friends to check out Zhihu more, remember this pitfall, and alert future generations

The above is the detailed content of Compatibility issues between python2 and 3 on Windows platform. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn