Python2.7 and 3.5 dual version coexistence and PIP usage

Source: Internet
Author: User
Tags sublime text

1. Python2.7 and 3.5 coexist 1.1 installation

Installation from needless to say, first installed 2.7, then 3.5.

Next installed directory: Py3.5 and Py2.7 The default installation directory is not the same, according to the default is good, no tube.

Python2.7: C:\Python27

Python3.5: C:\Users\Administrator\AppData\Local\Programs\Python\Python35

1.2 Environment variables

Install 2.7 and then install 3.5 is like 3.5 will replace the original 2.7 added to path, so you have to manually add 2.7.


1.3 Renaming

Before use, go to C:\Python27 to change Python.exe,pythonw.exe to python2.exe,pythonw2.exe

  To C:\Users\Administrator\AppData\Local\Programs\Python\Python35 Python.exe,pythonw.exe instead Python3.exe,pythonw3.exe

1.4 cmd into the corresponding interactive interface

After changing the name, it is convenient to distinguish the start.


1.5 py file specifies version run 1.5.1 cmd command line Interactive


1.5.2 Sublime The specified version runs

Open untitled.sublime-build edit by Arrow order first


Two operations, write the following code (change the CMD command and path according to your actual path and Python name, note that the path is '\ \'

# Python2

#Python2{ "cmd":["Python2.exe","- u","$file"], "Path":"c:\\python27", "File_regex":"^[]*file \ "(... *?) \ ", line ([0-9]*)", "selector":"Source.python"}

# Python3

#Python3{ "cmd":["Python3.exe","- u","$file"], "Path":"c:\\users\\administrator\\appdata\\local\\programs\\python\\python35", "File_regex":"^[]*file \ "(... *?) \ ", line ([0-9]*)", "selector":"Source.python"}

Note that the storage path (according to your actual situation):C:\Users\Administrator\AppData\Roaming\Sublime Text 3\packages\user

Then, when running with Ctrl+b, select the appropriate version in the Tools-build system

If I'm going to run with Python2, I'll choose.


2. Use of PIP 2.1 mounting module

# Python2

Python2-m pip Install module name

# Python3

Python3-m pip Install module name
2.2 Viewing versions

# Python2

Python2-m Pip--version#pip 9.0.1 from C:\Python27\lib\site-packages (Python 2.7)

# Python3

Python3-m Pip--version#pip 8.1.1 from C:\Users\Administrator\AppData\Local\Programs\Python\ Python35\lib\site-packages (Python 3.5)

2.3 View Library List

# Python2

python2-m PIP List

# Python3

python3-m PIP List

Python2 when viewing the list, when prompted as follows:

Deprecation:the default format would switch to columns in the future. You can use--format= (legacy|columns) (or define a format= (Legacy|columns) in your pip.conf under the [list] sections) to D Isable this warning.

  workaround : Create your own%appdata%\pip\pip.ini file and add the following file contents:


 Note:%appdata% can be run, input, enter into

The list is changed from left to right.

Python2.7 and 3.5 dual version coexistence and PIP usage

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: 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.