{"id":1090166,"date":"2025-01-08T14:00:14","date_gmt":"2025-01-08T06:00:14","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1090166.html"},"modified":"2025-01-08T14:00:17","modified_gmt":"2025-01-08T06:00:17","slug":"%e5%a6%82%e4%bd%95%e7%9c%8b%e8%87%aa%e5%b7%b1%e7%9a%84%e7%94%b5%e8%84%91%e6%9c%89python%e5%87%a0-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1090166.html","title":{"rendered":"\u5982\u4f55\u770b\u81ea\u5df1\u7684\u7535\u8111\u6709python\u51e0"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24202851\/d299c797-ec49-442c-83f8-26ce50368648.webp\" alt=\"\u5982\u4f55\u770b\u81ea\u5df1\u7684\u7535\u8111\u6709python\u51e0\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u770b\u81ea\u5df1\u7684\u7535\u8111\u6709 Python \u51e0<\/strong><\/p>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5\u3001\u4f7f\u7528 Python \u811a\u672c\u3001\u67e5\u770b\u5b89\u88c5\u76ee\u5f55\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/strong>\u3002\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5 Python \u7248\u672c\u3002\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165 <code>python --version<\/code> \u6216 <code>python3 --version<\/code>\uff0c\u5373\u53ef\u770b\u5230\u5f53\u524d\u5b89\u88c5\u7684 Python \u7248\u672c\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u4e0d\u540c\u7684\u65b9\u6cd5\u6765\u68c0\u67e5\u4f60\u7684\u7535\u8111\u4e0a\u6709\u51e0\u4e2a Python \u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08Mac\/Linux\uff09\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a\n<pre><code>python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5982\u679c\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u5982 <code>Python 3.8.5<\/code>\uff0c\u5219\u8868\u660e\u4f60\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u4e86 Python 3.8.5\u3002<\/li>\n<\/p>\n<li>\u82e5\u4f60\u7684\u7cfb\u7edf\u4e2d\u53ef\u80fd\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\uff0c\u53ef\u4ee5\u5c1d\u8bd5\uff1a\n<pre><code>python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8fd9\u901a\u5e38\u4f1a\u663e\u793a Python 3 \u7684\u7248\u672c\u4fe1\u606f\u3002<\/li>\n<\/p>\n<li>\u5bf9\u4e8e\u7279\u5b9a\u7684\u7248\u672c\uff0c\u53ef\u4ee5\u8f93\u5165\uff1a\n<pre><code>python2 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u4ee5\u67e5\u770b\u662f\u5426\u5b89\u88c5\u4e86 Python 2 \u7248\u672c\u3002<\/li>\n<\/p>\n<\/ol>\n<p><p>\u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5\u662f\u6700\u7b80\u5355\u548c\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u65e0\u8bba\u4f60\u4f7f\u7528\u7684\u662f Windows\u3001Mac \u8fd8\u662f Linux \u64cd\u4f5c\u7cfb\u7edf\uff0c\u8fd9\u79cd\u65b9\u6cd5\u90fd\u80fd\u6709\u6548\u5730\u5e2e\u52a9\u4f60\u5feb\u901f\u786e\u5b9a\u5f53\u524d\u5b89\u88c5\u7684 Python \u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528 Python \u811a\u672c<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u4f60\u5e38\u7528\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u6216 IDE\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Python \u6587\u4ef6\uff0c\u5982 <code>check_python_version.py<\/code>\u3002<\/li>\n<li>\u5728\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a\n<pre><code class=\"language-python\">import sys<\/p>\n<p>print(&quot;Python version&quot;)<\/p>\n<p>print(sys.version)<\/p>\n<p>print(&quot;Version info.&quot;)<\/p>\n<p>print(sys.version_info)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u4fdd\u5b58\u6587\u4ef6\u5e76\u8fd0\u884c\u5b83\u3002\u8be5\u811a\u672c\u4f1a\u8f93\u51fa\u8be6\u7ec6\u7684 Python \u7248\u672c\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u7248\u672c\u53f7\u3001\u6b21\u7248\u672c\u53f7\u548c\u4fee\u8ba2\u53f7\u3002<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528 Python \u811a\u672c\u7684\u65b9\u5f0f\u4e0d\u4ec5\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7684 Python \u7248\u672c\uff0c\u8fd8\u80fd\u83b7\u53d6\u66f4\u8be6\u7ec6\u7684\u7248\u672c\u4fe1\u606f\uff0c\u9002\u5408\u9700\u8981\u66f4\u591a\u6280\u672f\u7ec6\u8282\u7684\u7528\u6237\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u67e5\u770b\u5b89\u88c5\u76ee\u5f55<\/p>\n<\/p>\n<ol>\n<li>\u5728 Windows \u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u63a7\u5236\u9762\u677f\u6216\u8bbe\u7f6e\u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\u7ba1\u7406\u5668\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\uff0cPython \u901a\u5e38\u4f1a\u5217\u5728\u5176\u4e2d\u3002<\/li>\n<li>\u5728 Mac \u6216 Linux \u4e0a\uff0c\u53ef\u4ee5\u68c0\u67e5\u5e38\u89c1\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u5982 <code>\/usr\/bin\/python<\/code> \u6216 <code>\/usr\/local\/bin\/python<\/code>\u3002<\/li>\n<li>\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u627e Python \u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code>which python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u6216\u8005<\/p>\n<pre><code>which python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u67e5\u770b\u5b89\u88c5\u76ee\u5f55\u7684\u65b9\u6cd5\u9002\u7528\u4e8e\u90a3\u4e9b\u5e0c\u671b\u4e86\u89e3 Python \u5b89\u88c5\u4f4d\u7f6e\u7684\u7528\u6237\u3002\u8fd9\u5bf9\u4e8e\u914d\u7f6e\u5f00\u53d1\u73af\u5883\u6216\u6392\u9664\u73af\u5883\u53d8\u91cf\u95ee\u9898\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<ol>\n<li>\u5728 Windows \u4e0a\uff1a\n<ul>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u7cfb\u7edf\u53d8\u91cf\u6216\u7528\u6237\u53d8\u91cf\u4e2d\u67e5\u627e <code>Path<\/code>\uff0c\u5176\u4e2d\u5e94\u8be5\u5305\u542b Python \u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5728 Mac \u6216 Linux \u4e0a\uff1a\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165 <code>echo $PATH<\/code>\uff0c\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/li>\n<li>\u4f60\u5e94\u8be5\u80fd\u5728\u8f93\u51fa\u4e2d\u770b\u5230 Python \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5982 <code>\/usr\/local\/bin<\/code> \u6216 <code>\/usr\/bin<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u786e\u8ba4 Python \u7684\u5b89\u88c5\u8def\u5f84\u662f\u5426\u88ab\u6b63\u786e\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684 <code>PATH<\/code> \u4e2d\uff0c\u8fd9\u5bf9\u4e8e\u8fd0\u884c Python \u547d\u4ee4\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u56db\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5168\u9762\u4e86\u89e3\u4f60\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u4e86\u54ea\u4e9b Python \u7248\u672c\uff0c\u5e76\u83b7\u53d6\u8be6\u7ec6\u7684\u7248\u672c\u4fe1\u606f\u3002\u8fd9\u4e9b\u65b9\u6cd5\u4e0d\u4ec5\u9002\u7528\u4e8e\u65b0\u624b\uff0c\u4e5f\u9002\u7528\u4e8e\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u5728\u914d\u7f6e\u5f00\u53d1\u73af\u5883\u6216\u6392\u9664\u95ee\u9898\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770b\u6211\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u4e86\u54ea\u4e2a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u7535\u8111\u4e0a\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08Mac\/Linux\uff09\uff0c\u7136\u540e\u8f93\u5165\u547d\u4ee4 <code>python --version<\/code> \u6216 <code>python3 --version<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u7cfb\u7edf\u4e2d\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\u63d0\u793a\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u7684\u7535\u8111\u4e0a\u6ca1\u6709\u5b89\u88c5Python\uff0c\u5e94\u8be5\u5982\u4f55\u5b89\u88c5\uff1f<\/strong><br \/>\u5982\u679c\u53d1\u73b0\u7535\u8111\u4e0a\u6ca1\u6709Python\uff0c\u53ef\u4ee5\u524d\u5f80Python\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u5e76\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u7684\u6b65\u9aa4\u5b8c\u6210\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201c\u5c06Python\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u65b9\u4fbf\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5\u6211\u7535\u8111\u4e0a\u662f\u5426\u540c\u65f6\u5b89\u88c5\u4e86Python 2\u548cPython 3\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u5206\u522b\u8f93\u5165 <code>python --version<\/code> \u548c <code>python3 --version<\/code> \u6765\u68c0\u67e5\u662f\u5426\u540c\u65f6\u5b89\u88c5\u4e86Python 2\u548cPython 3\u3002\u5982\u679c\u4e24\u4e2a\u7248\u672c\u90fd\u5b58\u5728\uff0c\u547d\u4ee4\u884c\u4f1a\u5206\u522b\u8fd4\u56de\u5404\u81ea\u7684\u7248\u672c\u53f7\u3002\u5982\u679c\u53ea\u5b89\u88c5\u4e86\u5176\u4e2d\u4e00\u4e2a\u7248\u672c\uff0c\u53e6\u4e00\u4e2a\u7248\u672c\u7684\u547d\u4ee4\u5c06\u4f1a\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u770b\u81ea\u5df1\u7684\u7535\u8111\u6709 Python \u51e0 \u901a\u8fc7\u547d\u4ee4\u884c\u68c0\u67e5\u3001\u4f7f\u7528 Python \u811a\u672c\u3001\u67e5\u770b\u5b89\u88c5\u76ee\u5f55\u3001\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u53d8\u91cf [&hellip;]","protected":false},"author":3,"featured_media":1090173,"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\/1090166"}],"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=1090166"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1090166\/revisions"}],"predecessor-version":[{"id":1090174,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1090166\/revisions\/1090174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1090173"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1090166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1090166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1090166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}