{"id":1013488,"date":"2024-12-27T11:48:21","date_gmt":"2024-12-27T03:48:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1013488.html"},"modified":"2024-12-27T11:48:23","modified_gmt":"2024-12-27T03:48:23","slug":"python-exe%e5%a6%82%e4%bd%95%e7%94%9f%e6%88%90","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1013488.html","title":{"rendered":"python.exe\u5982\u4f55\u751f\u6210"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25090911\/1a5d9e2c-fdcb-4ef7-a96c-3e012ee9cdd3.webp\" alt=\"python.exe\u5982\u4f55\u751f\u6210\" \/><\/p>\n<p><p> <strong>Python.exe \u662f Python \u7f16\u8bd1\u5668\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7528\u4e8e\u5728 Windows \u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c Python \u811a\u672c\u3002\u751f\u6210 python.exe \u7684\u8fc7\u7a0b\u4e3b\u8981\u5305\u62ec\uff1a\u4e0b\u8f7d Python \u5b89\u88c5\u5305\u3001\u7f16\u8bd1 Python \u6e90\u4ee3\u7801\u3001\u4f7f\u7528\u7279\u5b9a\u5de5\u5177\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u76f4\u63a5\u4ece Python \u5b98\u7f51\u4e0b\u8f7d\u9884\u7f16\u8bd1\u7684\u5b89\u88c5\u5305\uff0c\u8fd9\u6837\u53ef\u4ee5\u7701\u53bb\u5f88\u591a\u590d\u6742\u7684\u6b65\u9aa4\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728 Windows \u4e0a\u751f\u6210 python.exe \u7684\u5177\u4f53\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d Python \u5b89\u88c5\u5305<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\u4ece Python \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408 Windows \u7684\u5b89\u88c5\u5305\u3002\u8bbf\u95ee <a href=\"https:\/\/www.python.org\/\">Python \u5b98\u7f51<\/a>\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u9009\u62e9\u9002\u5408\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u7684\u5b89\u88c5\u5305\uff08\u901a\u5e38\u662f Windows x86-64 executable installer\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5 Python<\/strong><\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u5305\u5f00\u59cb\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u4f60\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528 python.exe\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0cpython.exe \u5c31\u4f1a\u81ea\u52a8\u751f\u6210\u5728\u4f60\u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165 <code>python --version<\/code> \u6216 <code>python<\/code>\uff0c\u5982\u679c\u663e\u793a\u51fa Python \u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660e python.exe \u5df2\u7ecf\u6210\u529f\u751f\u6210\u5e76\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u83b7\u53d6 Python \u6e90\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49 Python \u7684\u7f16\u8bd1\u9009\u9879\uff0c\u53ef\u4ee5\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u3002\u5728 Python \u7684 <a href=\"https:\/\/github.com\/python\/cpython\">GitHub \u4ed3\u5e93<\/a> \u4e0a\u53ef\u4ee5\u83b7\u53d6\u5230\u6700\u65b0\u7684\u6e90\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u7f16\u8bd1\u5de5\u5177<\/strong><\/p>\n<\/p>\n<p><p>\u5728 Windows \u4e0a\u7f16\u8bd1 Python \u6e90\u4ee3\u7801\u9700\u8981\u5b89\u88c5 Microsoft Visual C++\uff08MSVC\uff09\u3002\u53ef\u4ee5\u901a\u8fc7 Visual Studio Installer \u5b89\u88c5\u201cDesktop development with C++\u201d\u5de5\u4f5c\u8d1f\u8f7d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1\u6e90\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5e76\u89e3\u538b Python \u6e90\u4ee3\u7801\u540e\uff0c\u6253\u5f00 Visual Studio \u7684\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5bfc\u822a\u5230\u6e90\u4ee3\u7801\u76ee\u5f55\uff0c\u8f93\u5165 <code>PCbuild\\build.bat<\/code> \u5f00\u59cb\u7f16\u8bd1\u3002\u7f16\u8bd1\u6210\u529f\u540e\uff0cpython.exe \u4f1a\u751f\u6210\u5728 <code>PCbuild\\amd64<\/code> \u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528 PyInstaller \u6253\u5305<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5 PyInstaller<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5df2\u7ecf\u6709 Python \u73af\u5883\uff0c\u53ef\u4ee5\u4f7f\u7528 PyInstaller \u5c06 Python \u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u9996\u5148\u901a\u8fc7 pip \u5b89\u88c5 PyInstaller\uff1a<code>pip install pyinstaller<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5305 Python \u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u5bfc\u822a\u5230\u4f60\u7684 Python \u811a\u672c\u6240\u5728\u76ee\u5f55\uff0c\u8f93\u5165 <code>pyinstaller --onefile your_script.py<\/code>\u3002\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u53ef\u6267\u884c\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5305\u5b8c\u6210\u540e\uff0c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f4d\u4e8e <code>dist<\/code> \u76ee\u5f55\u4e0b\u3002\u53cc\u51fb\u8fd0\u884c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u786e\u4fdd\u5176\u80fd\u591f\u6b63\u5e38\u6267\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5b9a\u5236\u5316 Python \u89e3\u91ca\u5668<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684 Python \u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u9009\u62e9 Python \u7248\u672c\u65f6\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u9879\u76ee\u9700\u6c42\u548c\u517c\u5bb9\u6027\u6765\u786e\u5b9a\u3002\u4e0d\u540c\u7248\u672c\u7684 Python \u53ef\u80fd\u5305\u542b\u4e0d\u540c\u7684\u7279\u6027\u548c\u6a21\u5757\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u81ea\u5b9a\u4e49\u7f16\u8bd1\u9009\u9879<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u7f16\u8bd1\u9636\u6bb5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 <code>PCbuild\\build.bat<\/code> \u4e2d\u7684\u9009\u9879\u6765\u5b9a\u5236\u4f60\u7684 Python \u89e3\u91ca\u5668\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u9009\u62e9\u7981\u7528\u6216\u542f\u7528\u67d0\u4e9b\u6269\u5c55\u6a21\u5757\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u548c\u90e8\u7f72<\/strong><\/p>\n<\/p>\n<p><p>\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u9700\u8981\u8fdb\u884c\u5168\u9762\u7684\u6d4b\u8bd5\uff0c\u786e\u4fdd\u6240\u6709\u529f\u80fd\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\u3002\u5c24\u5176\u662f\u5728\u5b9a\u5236\u4e86\u67d0\u4e9b\u6a21\u5757\u540e\uff0c\u66f4\u9700\u8981\u4ed4\u7ec6\u6d4b\u8bd5\u4ee5\u907f\u514d\u6f5c\u5728\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u751f\u6210\u5e76\u4f7f\u7528 python.exe\u3002\u4e0d\u540c\u7684\u65b9\u6cd5\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u9700\u6c42\u548c\u73af\u5883\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u8fdb\u884c Python \u5f00\u53d1\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u5b89\u88c5\u8fd8\u662f\u590d\u6742\u7684\u7f16\u8bd1\u4e0e\u5b9a\u5236\uff0c\u7406\u89e3\u6bcf\u4e00\u6b65\u7684\u539f\u7406\u548c\u64cd\u4f5c\u6b65\u9aa4\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e2d\u627e\u5230python.exe\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e2d\uff0cpython.exe\u901a\u5e38\u4f4d\u4e8ePython\u5b89\u88c5\u76ee\u5f55\u4e0b\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u60a8\u4f7f\u7528Python\u7684\u5b98\u65b9\u5b89\u88c5\u7a0b\u5e8f\u8fdb\u884c\u5b89\u88c5\uff0c\u901a\u5e38\u4f1a\u5728C:\\PythonXX\uff08XX\u4ee3\u8868\u7248\u672c\u53f7\uff09\u6216C:\\Users\\\u7528\u6237\u540d\\AppData\\Local\\Programs\\Python\\PythonXX\u76ee\u5f55\u4e2d\u627e\u5230\u5b83\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/58557.html\" target=\"_blank\">\u8d44\u6e90\u7ba1\u7406<\/a>\u5668\u5bfc\u822a\u5230\u8fd9\u4e9b\u4f4d\u7f6e\uff0c\u6216\u8005\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>where python<\/code>\u6765\u5feb\u901f\u67e5\u627e\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u901a\u8fc7\u54ea\u4e9b\u65b9\u5f0f\u5b89\u88c5Python\u4ee5\u751f\u6210python.exe\uff1f<\/strong><br \/>\u5b89\u88c5Python\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u4f8b\u5982\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982Anaconda\u6216Homebrew\uff09\uff0c\u6216\u4f7f\u7528Windows\u7684Microsoft Store\u3002\u5982\u679c\u9009\u62e9\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\uff0c\u786e\u4fdd\u4e0b\u8f7d\u4e0e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u9700\u6c42\u76f8\u5339\u914d\u7684\u7248\u672c\uff0c\u6267\u884c\u5b89\u88c5\u65f6\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u4e8e\u540e\u7eed\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u679c\u627e\u4e0d\u5230python.exe\uff0c\u5e94\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5982\u679c\u5728\u7cfb\u7edf\u4e2d\u627e\u4e0d\u5230python.exe\uff0c\u9996\u5148\u68c0\u67e5\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5Python\u3002\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u786e\u8ba4\u3002\u5982\u679c\u8fd4\u56de\u4fe1\u606f\u663e\u793a\u672a\u627e\u5230\u8be5\u547d\u4ee4\uff0c\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u5b89\u88c5Python\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9009\u62e9\u4e86\u5c06Python\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\u7684\u9009\u9879\uff0c\u6216\u8005\u624b\u52a8\u5c06\u5b89\u88c5\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python.exe \u662f Python \u7f16\u8bd1\u5668\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7528\u4e8e\u5728 Windows \u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c Pytho [&hellip;]","protected":false},"author":3,"featured_media":1013498,"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\/1013488"}],"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=1013488"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1013488\/revisions"}],"predecessor-version":[{"id":1013499,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1013488\/revisions\/1013499"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1013498"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1013488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1013488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1013488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}