{"id":939490,"date":"2024-12-26T20:36:26","date_gmt":"2024-12-26T12:36:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/939490.html"},"modified":"2024-12-26T20:36:28","modified_gmt":"2024-12-26T12:36:28","slug":"sublime%e5%a6%82%e4%bd%95%e5%85%81%e8%ae%b8python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/939490.html","title":{"rendered":"sublime\u5982\u4f55\u5141\u8bb8python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074502\/6d864822-843c-4585-9f02-d564949c825f.webp\" alt=\"sublime\u5982\u4f55\u5141\u8bb8python\" \/><\/p>\n<p><p> <strong>\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Package Control\u3001\u4f7f\u7528SublimeREPL\u63d2\u4ef6\u3001\u914d\u7f6eBuild System\u3002<\/strong>\u5176\u4e2d\uff0c\u914d\u7f6eBuild System\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u4f60\u5728Sublime Text\u4e2d\u76f4\u63a5\u8fd0\u884cPython\u4ee3\u7801\u5e76\u67e5\u770b\u7ed3\u679c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u914d\u7f6eBuild System\u6765\u8fd0\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5\u548c\u914d\u7f6eSublime Text<\/p>\n<\/p>\n<p><p>Sublime Text\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5176\u4e2dPython\u662f\u5176\u6700\u5e38\u7528\u7684\u8bed\u8a00\u4e4b\u4e00\u3002\u8981\u5728Sublime Text\u4e2d\u8fd0\u884cPython\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\uff0c\u5e76\u4e14\u5728\u7cfb\u7edf\u7684PATH\u4e2d\u53ef\u4ee5\u8c03\u7528\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d\u5e76\u5b89\u88c5Python<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528Python\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Sublime Text<\/strong><\/p>\n<\/p>\n<p><p>\u4eceSublime Text\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Sublime Text\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00Sublime Text\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u7b80\u6d01\u7684\u7528\u6237\u754c\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Package Control<\/strong><\/p>\n<\/p>\n<p><p>Package Control\u662fSublime Text\u7684\u4e00\u4e2a\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5141\u8bb8\u4f60\u8f7b\u677e\u5b89\u88c5\u548c\u7ba1\u7406\u63d2\u4ef6\u3002\u8981\u5b89\u88c5Package Control\uff0c\u6309\u4e0bCtrl + `\uff08\u53cd\u5f15\u53f7\uff09\u6253\u5f00\u63a7\u5236\u53f0\uff0c\u7136\u540e\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\u5e76\u6309Enter\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import urllib.request,os,hashlib; h = &#39;65f3ddf9e1c4a8d3e63c5f2c7e8b5e0d&#39; + &#39;7b1b1e4e9f4b2b2f0b7d2f0b9f5e3f0d&#39;; pf = &#39;Package Control.sublime-package&#39;; ipp = sublime.installed_packages_path(); os.makedirs(ipp, exist_ok=True); urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler())); by = urllib.request.urlopen(&#39;http:\/\/packagecontrol.io\/&#39; + pf.replace(&#39; &#39;, &#39;%20&#39;)).read(); dh = hashlib.sha256(by).hexdigest(); open(os.path.join(ipp, pf), &#39;wb&#39;).write(by) if dh == h else None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u542fSublime Text\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u914d\u7f6eBuild System<\/p>\n<\/p>\n<p><p>\u914d\u7f6eBuild System\u662f\u8ba9Sublime Text\u80fd\u591f\u76f4\u63a5\u8fd0\u884cPython\u4ee3\u7801\u7684\u5173\u952e\u6b65\u9aa4\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u7684Build System<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00Sublime Text\uff0c\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u201cTools\u201d -&gt; \u201cBuild System\u201d -&gt; \u201cNew Build System\u2026\u201d\u3002\u5728\u65b0\u5efa\u7684\u6587\u4ef6\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;cmd&quot;: [&quot;python3&quot;, &quot;-u&quot;, &quot;$file&quot;],<\/p>\n<p>    &quot;file_regex&quot;: &quot;^[ ]*File \\&quot;(...*?)\\&quot;, line ([0-9]*)&quot;,<\/p>\n<p>    &quot;selector&quot;: &quot;source.python&quot;,<\/p>\n<p>    &quot;shell&quot;: true<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684<code>&quot;python3&quot;<\/code>\u53ef\u4ee5\u6839\u636e\u4f60\u7684Python\u5b89\u88c5\u7248\u672c\u8fdb\u884c\u8c03\u6574\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fWindows\u7cfb\u7edf\uff0c\u53ef\u80fd\u9700\u8981\u5c06\u5176\u6539\u4e3a<code>&quot;python&quot;<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58Build System<\/strong><\/p>\n<\/p>\n<p><p>\u5c06\u8fd9\u4e2a\u6587\u4ef6\u4fdd\u5b58\u4e3a<code>Python3.sublime-build<\/code>\uff08\u6587\u4ef6\u540d\u53ef\u4ee5\u81ea\u5b9a\u4e49\uff09\uff0c\u4fdd\u5b58\u540e\uff0cSublime Text\u4f1a\u81ea\u52a8\u8bc6\u522b\u8fd9\u4e2a\u65b0\u7684Build System\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9Build System<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u4f60\u60f3\u8981\u8fd0\u884c\u7684Python\u6587\u4ef6\uff0c\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u201cTools\u201d -&gt; \u201cBuild System\u201d\uff0c\u9009\u62e9\u4f60\u521a\u521a\u521b\u5efa\u7684<code>Python3<\/code>\u3002\u7136\u540e\u6309\u4e0bCtrl + B\uff08Windows\uff09\u6216Cmd + B\uff08Mac\uff09\uff0cSublime Text\u5c31\u4f1a\u5728\u5e95\u90e8\u7684\u63a7\u5236\u53f0\u4e2d\u8fd0\u884c\u4f60\u7684Python\u4ee3\u7801\uff0c\u5e76\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528SublimeREPL\u63d2\u4ef6<\/p>\n<\/p>\n<p><p>\u867d\u7136\u914d\u7f6eBuild System\u5df2\u7ecf\u53ef\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u9700\u6c42\uff0c\u4f46\u5bf9\u4e8e\u9700\u8981\u4ea4\u4e92\u5f0f\u8fd0\u884cPython\u4ee3\u7801\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528SublimeREPL\u63d2\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5SublimeREPL<\/strong><\/p>\n<\/p>\n<p><p>\u6309\u4e0bCtrl + Shift + P\uff08Windows\uff09\u6216Cmd + Shift + P\uff08Mac\uff09\uff0c\u8f93\u5165\u201cInstall Package\u201d\u5e76\u9009\u62e9\u201cPackage Control: Install Package\u201d\u3002\u7136\u540e\u5728\u5f39\u51fa\u7684\u8f93\u5165\u6846\u4e2d\u8f93\u5165\u201cSublimeREPL\u201d\u5e76\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u4f60\u60f3\u8981\u8fd0\u884c\u7684Python\u6587\u4ef6\uff0c\u6309\u4e0bCtrl + Shift + P\uff08Windows\uff09\u6216Cmd + Shift + P\uff08Mac\uff09\uff0c\u8f93\u5165\u201cSublimeREPL: Python\u201d\u5e76\u9009\u62e9\u3002\u8fd9\u6837\u4f1a\u6253\u5f00\u4e00\u4e2a\u65b0\u7684REPL\u7a97\u53e3\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5176\u4ed6\u6280\u5de7\u548c\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5feb\u6377\u952e<\/strong><\/p>\n<\/p>\n<p><p>\u5728Sublime Text\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u5feb\u6377\u952e\u6765\u63d0\u9ad8\u6548\u7387\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5feb\u6377\u952e\uff0c\u4ee5\u5feb\u901f\u5207\u6362Build System\u6216\u8fd0\u884c\u7279\u5b9a\u7684\u811a\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u529f\u80fd<\/strong><\/p>\n<\/p>\n<p><p>Sublime Text\u672c\u8eab\u4e0d\u63d0\u4f9b\u8c03\u8bd5\u529f\u80fd\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u7b2c\u4e09\u65b9\u63d2\u4ef6\uff08\u5982Anaconda\u63d2\u4ef6\uff09\u6765\u5b9e\u73b0Python\u4ee3\u7801\u7684\u8c03\u8bd5\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u63d2\u4ef6\u7ba1\u7406<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Package Control\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u548c\u66f4\u65b0\u63d2\u4ef6\uff0c\u786e\u4fddSublime Text\u59cb\u7ec8\u4fdd\u6301\u6700\u65b0\u548c\u6700\u7a33\u5b9a\u7684\u72b6\u6001\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e2a\u6027\u5316\u914d\u7f6e<\/strong><\/p>\n<\/p>\n<p><p>Sublime Text\u652f\u6301\u9ad8\u5ea6\u4e2a\u6027\u5316\u7684\u8bbe\u7f6e\uff0c\u5305\u62ec\u4e3b\u9898\u3001\u914d\u8272\u65b9\u6848\u548c\u4ee3\u7801\u7247\u6bb5\u3002\u901a\u8fc7\u8c03\u6574\u8fd9\u4e9b\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6700\u9002\u5408\u81ea\u5df1\u5f00\u53d1\u4e60\u60ef\u7684\u7f16\u7a0b\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728Sublime Text\u4e2d\u6d41\u7545\u5730\u8fd0\u884cPython\u4ee3\u7801\uff0c\u5e76\u4eab\u53d7\u8fd9\u6b3e\u7f16\u8f91\u5668\u7684\u9ad8\u6548\u4e0e\u4fbf\u6377\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u811a\u672c\u8fd8\u662f\u590d\u6742\u7684\u9879\u76ee\uff0cSublime Text\u90fd\u80fd\u4e3a\u60a8\u63d0\u4f9b\u826f\u597d\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Sublime Text\u4e2d\u8bbe\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\u8981\u5728Sublime Text\u4e2d\u8bbe\u7f6ePython\u73af\u5883\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u3002\u63a5\u7740\uff0c\u6253\u5f00Sublime Text\uff0c\u9009\u62e9\u201cPreferences\u201d &gt; \u201cPackage Control\u201d\uff0c\u7136\u540e\u5b89\u88c5\u201cAnaconda\u201d\u6216\u5176\u4ed6Python\u76f8\u5173\u63d2\u4ef6\u3002\u8fd9\u4e9b\u63d2\u4ef6\u5c06\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u8865\u5168\u548c\u9519\u8bef\u68c0\u67e5\u7b49\u529f\u80fd\u3002\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u65b0\u6587\u4ef6\u4e2d\u7f16\u5199Python\u4ee3\u7801\u5e76\u4f7f\u7528\u201cTools\u201d &gt; \u201cBuild\u201d\u6765\u8fd0\u884c\u4ee3\u7801\u3002<\/p>\n<p><strong>Sublime Text\u652f\u6301\u54ea\u4e9bPython\u7248\u672c\uff1f<\/strong><br \/>Sublime Text\u652f\u6301Python 2\u548cPython 3\u7684\u8fd0\u884c\u3002\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c\u3002\u901a\u5e38\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7248\u672c\u7684Python 3\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u529f\u80fd\u548c\u6027\u80fd\u3002\u5728\u8bbe\u7f6ePython\u73af\u5883\u65f6\uff0c\u786e\u4fdd\u5df2\u6b63\u786e\u914d\u7f6ePython\u7684\u8def\u5f84\uff0c\u4ee5\u907f\u514d\u7248\u672c\u51b2\u7a81\u3002<\/p>\n<p><strong>\u5728Sublime Text\u4e2d\u5982\u4f55\u8c03\u8bd5Python\u4ee3\u7801\uff1f<\/strong><br \/>\u8981\u5728Sublime Text\u4e2d\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cAnaconda\u201d\u6216\u201cSublimeREPL\u201d\u7b49\u63d2\u4ef6\u3002\u5b89\u88c5\u8fd9\u4e9b\u63d2\u4ef6\u540e\uff0c\u60a8\u53ef\u4ee5\u5728Sublime Text\u4e2d\u76f4\u63a5\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801\uff0c\u67e5\u770b\u53d8\u91cf\u503c\u4ee5\u53ca\u5904\u7406\u5f02\u5e38\u7b49\u3002\u8c03\u8bd5\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528Python\u7684\u5185\u7f6e\u8c03\u8bd5\u5de5\u5177\u5982pdb\uff0c\u4ee5\u4fbf\u66f4\u6df1\u5165\u5730\u5206\u6790\u4ee3\u7801\u6267\u884c\u60c5\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Package Control\u3001\u4f7f\u7528Subli [&hellip;]","protected":false},"author":3,"featured_media":939491,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939490"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=939490"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939490\/revisions"}],"predecessor-version":[{"id":939492,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939490\/revisions\/939492"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/939491"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=939490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=939490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=939490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}