Home > Article > Development Tools > Press ctrl+B in sublime to call python3 to run
Write the complete python3.exe path under the windows system.
The following is the operation of macOS, which is similar to that of windows.
Written the code for python3 using sublime text, but ctrl B called python2 when running, causing an error to be reported.
This is because many systems have python2 installed by default, and the default version of python called is python2.
Solution:
Let’s first create a new sublime build system
and then automatically open a text , clear and write the following content:
{ "env": {"PYTHONIOENCODING": "utf8"}, "cmd": ["/Library/Frameworks/Python.framework/Versions/3.6/bin/python3", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python" }
"env": {"PYTHONIOENCODING": "utf8"}, to avoid Chinese errors!
[“/Library/Frameworks/Python.framework/Versions/3.6/bin/python3”, “-u”, “$file”], the path here should be replaced with the path of python3 in your computer.
Check the path of python3
$ which python3 /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Then, save the file name as python3.sublime-build
Then, select python3
Let’s verify the following, whether the current version is python3
import sys print(sys.version)
Press ctrl B to run, the results are as follows
3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] [Finished in 0.1s]
End
For more sublime related technical articles, please visit sublime column.
The above is the detailed content of Press ctrl+B in sublime to call python3 to run. For more information, please follow other related articles on the PHP Chinese website!