1. Python2.7 and 3.5 coexist
1.1 Installation
Installation does not need to say more, install 2.7 first, and then install 3.5.
Say the installation directory: PY3.5 and PY2.7 default installation directory is different, just follow the default ones, don’t care.
Python2.7: C:\Python27
Python3.5: C:\Users\Administrator\AppData\Local\Programs\Python\Python35
1.2 Environment variables
First install 2.7 and then install 3.5 as if 3.5 will be replaced to the original 2.7 to add to Path, so you must add 2.7 manually.
1.3 renamed
Before using it, get to use it
C:\Python27 Python.exe, pythonw.exe topython2.exe,pythonw2.exe
C:\Users\Administrator\AppData\Local\Programs\Python\Python35 python.exe, pythonw.exe changed topython3.exe,pythonw3.exe
1.4 CMD Enter the corresponding interactive interface
After the name is changed, it is convenient to distinguish.
1.5 PY file designated version run
1.5.1 CMD command line interactive style
1.5.2 Sublime designated version run
Open in the order of the arrow firstuntitled.sublime-build Edit
Two operations, write the following code (change the CMD command and path according to your actual path and Python name, pay attention to the path\\‘
# 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" }
When note, the storage path (according to the actual situation of you):C:\Users\Administrator\AppData\Roaming\Sublime Text 3\Packages\User
and then run with ctrl+B, choose the corresponding version in Tools-Build System
If I want to run in Python2, choose the figure as shown in the figure
2. PIP use
2.1 Installation module
# python2
python2 -m PIP Install module name
# python3
python3 -m PIP Install module name
2.2 View version
# 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, as the prompts are as follows:
DEPRECATION: The default format will 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] section) to disable this warning.
Solution: Create%appdata%\ pip \ pip.ini file yourself, add the following file content:
[list]
format=columns
Note:% AppData % can run, enter, return into
After the solution, List changes from the left to the right