{"id":1102345,"date":"2025-01-08T15:58:55","date_gmt":"2025-01-08T07:58:55","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1102345.html"},"modified":"2025-01-08T15:58:58","modified_gmt":"2025-01-08T07:58:58","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%8d%b8%e8%bd%bd%e5%bd%93%e5%89%8d%e7%89%88%e6%9c%acpython-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1102345.html","title":{"rendered":"\u5982\u4f55\u901a\u8fc7\u547d\u4ee4\u884c\u5378\u8f7d\u5f53\u524d\u7248\u672cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25064705\/9569c1e5-de1f-4ebc-adb7-d3c8be24301d.webp\" alt=\"\u5982\u4f55\u901a\u8fc7\u547d\u4ee4\u884c\u5378\u8f7d\u5f53\u524d\u7248\u672cpython\" \/><\/p>\n<p><p> <strong>\u901a\u8fc7\u547d\u4ee4\u884c\u5378\u8f7d\u5f53\u524d\u7248\u672cPython\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3001\u4f7f\u7528\u4e13\u7528\u7684\u5378\u8f7d\u5de5\u5177\u4ee5\u53ca\u624b\u52a8\u5220\u9664\u3002\u6700\u5e38\u7528\u7684\u65b9\u5f0f\u6709\uff1a\u4f7f\u7528Windows\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u3001macOS\u7684Terminal\u4ee5\u53caLinux\u7684Terminal\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6b65\u9aa4\uff1a<\/strong><\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3001\u4f7f\u7528\u4e13\u7528\u7684\u5378\u8f7d\u5de5\u5177\u3001\u624b\u52a8\u5220\u9664<\/strong>\u3002\u5728\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u65f6\uff0c\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6709\u4e0d\u540c\u7684\u5de5\u5177\uff0c\u4f8b\u5982Windows\u4f7f\u7528<code>winget<\/code>\u6216<code>choco<\/code>\uff0cmacOS\u4f7f\u7528<code>brew<\/code>\uff0c\u800cLinux\u5219\u4f7f\u7528<code>apt<\/code>\u3001<code>yum<\/code>\u6216<code>dnf<\/code>\u7b49\u3002\u4ee5\u4e0b\u8be6\u7ec6\u63cf\u8ff0\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001WINDOWS\u7cfb\u7edf<\/h3>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u6765\u5378\u8f7dPython\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6309<code>Win + R<\/code>\u952e\uff0c\u8f93\u5165<code>cmd<\/code>\uff0c\u7136\u540e\u6309<code>Enter<\/code>\u952e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u8f93\u5165<code>python --version<\/code>\u6765\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>Windows\u7cfb\u7edf\u4e2d\u63a8\u8350\u4f7f\u7528<code>winget<\/code>\u6216<code>choco<\/code>\u5305\u7ba1\u7406\u5668\u3002<\/li>\n<li>\u5982\u679c\u4f7f\u7528<code>winget<\/code>\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-cmd\">winget uninstall Python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5982\u679c\u4f7f\u7528<code>choco<\/code>\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-cmd\">choco uninstall python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u624b\u52a8\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u6ca1\u6709\u5b89\u88c5\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u624b\u52a8\u5378\u8f7dPython\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code class=\"language-cmd\">where python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u7136\u540e\u5220\u9664\u627e\u5230\u7684\u8def\u5f84\u4e0b\u7684Python\u6587\u4ef6\u5939\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001MACOS\u7cfb\u7edf<\/h3>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Terminal<\/h4>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7Terminal\u6765\u5378\u8f7dPython\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00Terminal<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6309<code>Command + Space<\/code>\u952e\uff0c\u8f93\u5165<code>Terminal<\/code>\uff0c\u7136\u540e\u6309<code>Enter<\/code>\u952e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u8f93\u5165<code>python --version<\/code>\u6765\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Homebrew\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>macOS\u7cfb\u7edf\u4e2d\u63a8\u8350\u4f7f\u7528<code>brew<\/code>\u5305\u7ba1\u7406\u5668\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5378\u8f7dPython\uff1a\n<pre><code class=\"language-sh\">brew uninstall python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u624b\u52a8\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u6ca1\u6709\u5b89\u88c5<code>brew<\/code>\uff0c\u53ef\u4ee5\u624b\u52a8\u5378\u8f7dPython\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code class=\"language-sh\">which python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u7136\u540e\u5220\u9664\u627e\u5230\u7684\u8def\u5f84\u4e0b\u7684Python\u6587\u4ef6\u5939\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001LINUX\u7cfb\u7edf<\/h3>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Terminal<\/h4>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7Terminal\u6765\u5378\u8f7dPython\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00Terminal<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl + Alt + T<\/code>\u6765\u6253\u5f00Terminal\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u5df2\u5b89\u88c5\u7684Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u8f93\u5165<code>python --version<\/code>\u6765\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u6839\u636e\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\uff0c\u4f7f\u7528\u76f8\u5e94\u7684\u5305\u7ba1\u7406\u5668\u5378\u8f7dPython\u3002<\/li>\n<li>\u5982\u679c\u4f7f\u7528<code>apt<\/code>\uff08\u9002\u7528\u4e8eUbuntu\/Debian\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-sh\">sudo apt-get remove python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5982\u679c\u4f7f\u7528<code>yum<\/code>\uff08\u9002\u7528\u4e8eCentOS\/RHEL\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-sh\">sudo yum remove python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5982\u679c\u4f7f\u7528<code>dnf<\/code>\uff08\u9002\u7528\u4e8eFedora\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code class=\"language-sh\">sudo dnf remove python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u624b\u52a8\u5378\u8f7dPython<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5982\u679c\u6ca1\u6709\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u624b\u52a8\u5378\u8f7dPython\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u627e\u5230Python\u7684\u5b89\u88c5\u8def\u5f84\uff1a\n<pre><code class=\"language-sh\">which python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u7136\u540e\u5220\u9664\u627e\u5230\u7684\u8def\u5f84\u4e0b\u7684Python\u6587\u4ef6\u5939\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5907\u4efd\u91cd\u8981\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5728\u5378\u8f7dPython\u4e4b\u524d\uff0c\u786e\u4fdd\u5907\u4efd\u6240\u6709\u91cd\u8981\u7684Python\u811a\u672c\u548c\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u4f9d\u8d56\u9879<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u6ca1\u6709\u5176\u4ed6\u7a0b\u5e8f\u4f9d\u8d56\u4e8e\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u4ee5\u907f\u514d\u5378\u8f7d\u540e\u51fa\u73b0\u95ee\u9898\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6e05\u7406\u6b8b\u7559\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5378\u8f7dPython\u540e\uff0c\u68c0\u67e5\u5e76\u6e05\u7406\u6b8b\u7559\u7684\u914d\u7f6e\u6587\u4ef6\u548c\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u901a\u8fc7\u547d\u4ee4\u884c\u5378\u8f7d\u5f53\u524d\u7248\u672c\u7684Python\u3002\u786e\u4fdd\u6309\u7167\u5177\u4f53\u7684\u64cd\u4f5c\u6b65\u9aa4\u8fdb\u884c\uff0c\u4ee5\u907f\u514d\u51fa\u73b0\u4e0d\u5fc5\u8981\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u5b9a\u6211\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u60a8\u7cfb\u7edf\u4e0a\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fWindows\u7cfb\u7edf\uff0c\u786e\u4fdd\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u6267\u884c\u8be5\u547d\u4ee4\uff1b\u5728Linux\u6216macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u3002<\/p>\n<p><strong>\u5728\u5378\u8f7dPython\u4e4b\u524d\uff0c\u6211\u9700\u8981\u5907\u4efd\u54ea\u4e9b\u6587\u4ef6\u5417\uff1f<\/strong><br \/>\u5728\u5378\u8f7dPython\u4e4b\u524d\uff0c\u5efa\u8bae\u5907\u4efd\u60a8\u53ef\u80fd\u9700\u8981\u7684\u4efb\u4f55Python\u9879\u76ee\u3001\u865a\u62df\u73af\u5883\u6216\u76f8\u5173\u7684\u4f9d\u8d56\u6587\u4ef6\u3002\u5982\u679c\u60a8\u5728\u4f7f\u7528pip\u5b89\u88c5\u4e86\u8bb8\u591a\u5e93\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>pip freeze &gt; requirements.txt<\/code>\u5c06\u5f53\u524d\u73af\u5883\u4e2d\u7684\u6240\u6709\u5e93\u53ca\u5176\u7248\u672c\u5bfc\u51fa\u5230\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728\u4e4b\u540e\u91cd\u65b0\u5b89\u88c5\u65f6\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u5378\u8f7d\u4e86Python\uff0c\u5982\u4f55\u91cd\u65b0\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff1f<\/strong><br \/>\u5378\u8f7dPython\u540e\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\uff0c\u4e0b\u8f7d\u540e\u6839\u636e\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9009\u4e2d\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u65b9\u4fbf\u5730\u4f7f\u7528Python\u3002\u5bf9\u4e8eLinux\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982<code>apt<\/code>\u6216<code>yum<\/code>\uff09\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u901a\u8fc7\u547d\u4ee4\u884c\u5378\u8f7d\u5f53\u524d\u7248\u672cPython\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3001\u4f7f\u7528\u4e13\u7528\u7684\u5378\u8f7d\u5de5\u5177\u4ee5\u53ca\u624b\u52a8\u5220\u9664\u3002\u6700\u5e38\u7528\u7684 [&hellip;]","protected":false},"author":3,"featured_media":1102350,"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\/1102345"}],"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=1102345"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1102345\/revisions"}],"predecessor-version":[{"id":1102353,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1102345\/revisions\/1102353"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1102350"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1102345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1102345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1102345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}