Running files with Python3 in sublime text

Source: Internet
Author: User
Tags sublime text


EditRunning files with Python3 in sublime text


In sublime text you cancmd + bquickly run a python file using the shortcut key (Windows YesCTRL + b), and Sublime will directly invoke the system default Python run file and pop up the results in the box below.






What if we want to use our own Python version, such as Python3 or other third-party python packages (such as the one I use anaconda)?


Sublime Usecmd+bOperation is calledbuildInTools -> Build SystemYou can see the types that the system supports by default, includingC++、JavaAnd so on, the default choice isAutomatic, the appropriate build method is automatically selected based on the file name extension.







Operation method
  1. To use the custom Reach method, select the followingNew Build System..., which will pop up asublime-buildfile with the suffix.
  2. In the open file, fill in the following content:
    {
     "cmd": ["/usr/local/bin/python3", "-u", "$file"],
     "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
     "selector": "source.python" }
    Then save the file name aspython3.sublime-build, the file is automatically saved to a custom folder in sublime, and the default is~/Library/Application Support/Sublime Text 2/Packages/User
  3. Re-enter theBuild Systemtab, you will find a python3 added below, select the item.
  4. cmd+bwhen you press the run file again, Sublime will run the file with Python3. Because thisprintstatement does not conform to PYTHON3 syntax, it is an error.


Sublime text in Python3 run file


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.