{"id":997628,"date":"2024-12-27T09:25:49","date_gmt":"2024-12-27T01:25:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/997628.html"},"modified":"2024-12-27T09:25:52","modified_gmt":"2024-12-27T01:25:52","slug":"%e5%a6%82%e4%bd%95%e5%8d%b8%e8%bd%bd%e5%8e%9f%e6%9d%a5%e7%9a%84python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/997628.html","title":{"rendered":"\u5982\u4f55\u5378\u8f7d\u539f\u6765\u7684python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25073356\/5394abf5-7da3-4b6e-88c8-a5fad353f39d.webp\" alt=\"\u5982\u4f55\u5378\u8f7d\u539f\u6765\u7684python\" \/><\/p>\n<p><p> <strong>\u5378\u8f7d\u539f\u6765\u7684Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u8fdb\u884c\uff1a\u9996\u5148\uff0c\u4f7f\u7528\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177\u5378\u8f7d\u3001\u5176\u6b21\uff0c\u5220\u9664\u6b8b\u7559\u6587\u4ef6\u548c\u73af\u5883\u53d8\u91cf\u3001\u6700\u540e\uff0c\u9a8c\u8bc1\u5378\u8f7d\u662f\u5426\u6210\u529f\u3002<\/strong> \u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Windows\u3001macOS\u548cLinux\u7cfb\u7edf\u4e0a\u5378\u8f7dPython\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001WINDOWS\u7cfb\u7edf\u4e0a\u5378\u8f7dPYTHON<\/h3>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u63a7\u5236\u9762\u677f\u5378\u8f7dPython<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u63a7\u5236\u9762\u677f\u5378\u8f7dPython\u3002\u8fdb\u5165\u63a7\u5236\u9762\u677f\uff0c\u9009\u62e9\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\uff0c\u627e\u5230Python\u7a0b\u5e8f\uff0c\u70b9\u51fb\u5378\u8f7d\u3002\u8fd9\u5c06\u79fb\u9664Python\u7684\u4e3b\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>2. \u5220\u9664\u6b8b\u7559\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u867d\u7136\u901a\u8fc7\u63a7\u5236\u9762\u677f\u5378\u8f7d\u53ef\u4ee5\u5220\u9664\u5927\u90e8\u5206\u6587\u4ef6\uff0c\u4f46\u6709\u65f6\u4ecd\u4f1a\u9057\u7559\u4e00\u4e9b\u6587\u4ef6\u3002\u53ef\u4ee5\u624b\u52a8\u68c0\u67e5\u4ee5\u4e0b\u4f4d\u7f6e\uff0c\u5e76\u5220\u9664\u76f8\u5173\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<ul>\n<li><code>C:\\PythonXX<\/code> (XX\u4e3aPython\u7248\u672c\u53f7)<\/li>\n<li><code>C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\PythonXX<\/code><\/li>\n<li><code>C:\\Users\\YourUsername\\AppData\\Roaming\\Python<\/code><\/li>\n<\/ul>\n<p><h4>3. \u79fb\u9664\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5378\u8f7dPython\u540e\uff0c\u5efa\u8bae\u68c0\u67e5\u5e76\u79fb\u9664\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u7684Python\u8def\u5f84\u3002\u53f3\u952e\u201c\u6b64\u7535\u8111\u201d\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u8fdb\u5165\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\uff0c\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u6216\u201c\u7528\u6237\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u4e0ePython\u76f8\u5173\u7684\u8def\u5f84\u5e76\u5220\u9664\u3002<\/p>\n<\/p>\n<p><h4>4. \u9a8c\u8bc1\u5378\u8f7d<\/h4>\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\u8fd4\u56de\u201c\u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\u201d\uff0c\u5219\u8868\u793a\u5378\u8f7d\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001MACOS\u7cfb\u7edf\u4e0a\u5378\u8f7dPYTHON<\/h3>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u7ec8\u7aef\u5220\u9664Python<\/h4>\n<\/p>\n<p><p>macOS\u81ea\u5e26\u4e86Python\uff0c\u901a\u5e38\u662f\u4e0d\u5efa\u8bae\u5378\u8f7d\u7684\uff0c\u4f46\u5982\u679c\u5b89\u88c5\u4e86\u5176\u4ed6\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u6765\u5220\u9664\u3002\u9996\u5148\uff0c\u67e5\u627ePython\u7684\u5b89\u88c5\u4f4d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which python<\/p>\n<p>which python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u76f8\u5e94\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo rm -rf \/Library\/Frameworks\/Python.framework\/Versions\/3.X<\/p>\n<p>sudo rm -rf &quot;\/Applications\/Python 3.X&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5220\u9664\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u7f16\u8f91<code>~\/.bash_profile<\/code>\u3001<code>~\/.zshrc<\/code>\u6216<code>~\/.bashrc<\/code>\u6587\u4ef6\uff0c\u5220\u9664\u4e0ePython\u76f8\u5173\u7684\u8def\u5f84\u3002\u4fdd\u5b58\u5e76\u9000\u51fa\u540e\uff0c\u8fd0\u884c<code>source ~\/.bash_profile<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<\/p>\n<p><h4>3. \u9a8c\u8bc1\u5378\u8f7d<\/h4>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u663e\u793a\u9519\u8bef\u4fe1\u606f\uff0c\u8868\u793a\u5df2\u6210\u529f\u5378\u8f7d\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001LINUX\u7cfb\u7edf\u4e0a\u5378\u8f7dPYTHON<\/h3>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5378\u8f7d<\/h4>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5982<code>apt<\/code>\u3001<code>yum<\/code>\u3001<code>dnf<\/code>\u7b49\u5378\u8f7dPython\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e0a\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get remove python3.X<\/p>\n<p>sudo apt-get autoremove<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728CentOS\u4e0a\u5219\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum remove python3.X<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5220\u9664\u6b8b\u7559\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u68c0\u67e5\u7528\u6237\u76ee\u5f55\u4e0b\u7684<code>.local<\/code>\u3001<code>.cache<\/code>\u3001<code>.config<\/code>\u7b49\u6587\u4ef6\u5939\uff0c\u5220\u9664\u4e0ePython\u76f8\u5173\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>3. \u79fb\u9664\u73af\u5883\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.zshrc<\/code>\u6587\u4ef6\uff0c\u5220\u9664\u4e0ePython\u76f8\u5173\u7684\u8def\u5f84\u3002\u8fd0\u884c<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.zshrc<\/code>\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<\/p>\n<p><h4>4. \u9a8c\u8bc1\u5378\u8f7d<\/h4>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u5982\u679c\u672a\u627e\u5230\u547d\u4ee4\uff0c\u5219\u8868\u793a\u5378\u8f7d\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<p><h4>1. \u7cfb\u7edf\u81ea\u5e26Python\u7684\u91cd\u8981\u6027<\/h4>\n<\/p>\n<p><p>\u8bb8\u591a\u7cfb\u7edf\u5de5\u5177\u548c\u811a\u672c\u4f9d\u8d56\u4e8e\u7cfb\u7edf\u81ea\u5e26\u7684Python\u7248\u672c\uff0c\u5378\u8f7d\u5b83\u4eec\u53ef\u80fd\u5bfc\u81f4\u7cfb\u7edf\u4e0d\u7a33\u5b9a\u3002\u56e0\u6b64\uff0c\u5728\u5378\u8f7dPython\u65f6\uff0c\u8bf7\u786e\u4fdd\u662f\u5378\u8f7d\u7528\u6237\u5b89\u88c5\u7684\u7248\u672c\uff0c\u800c\u975e\u7cfb\u7edf\u81ea\u5e26\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>2. \u5907\u4efd\u91cd\u8981\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5728\u5378\u8f7d\u4e4b\u524d\uff0c\u786e\u4fdd\u5907\u4efd\u6240\u6709\u91cd\u8981\u7684Python\u9879\u76ee\u548c\u811a\u672c\uff0c\u4ee5\u514d\u5728\u5378\u8f7d\u8fc7\u7a0b\u4e2d\u4e22\u5931\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>3. \u4f7f\u7528\u865a\u62df\u73af\u5883<\/h4>\n<\/p>\n<p><p>\u4e3a\u907f\u514dPython\u73af\u5883\u51b2\u7a81\uff0c\u63a8\u8350\u4f7f\u7528<code>virtualenv<\/code>\u6216<code>conda<\/code>\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\u3002\u8fd9\u4e0d\u4ec5\u53ef\u4ee5\u7b80\u5316Python\u7248\u672c\u7ba1\u7406\uff0c\u8fd8\u80fd\u5728\u4e0d\u5f71\u54cd\u7cfb\u7edf\u73af\u5883\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<\/p>\n<p><h4>4. \u7248\u672c\u7ba1\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u9891\u7e41\u5207\u6362Python\u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528<code>pyenv<\/code>\u6216<code>anaconda<\/code>\u7b49\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3002\u8fd9\u4e9b\u5de5\u5177\u5141\u8bb8\u5728\u591a\u4e2aPython\u7248\u672c\u4e4b\u95f4\u8f7b\u677e\u5207\u6362\u548c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0c\u5378\u8f7dPython\u9700\u8981\u5c0f\u5fc3\u8c28\u614e\uff0c\u4ee5\u514d\u5f71\u54cd\u7cfb\u7edf\u7684\u6b63\u5e38\u8fd0\u884c\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5b89\u5168\u5730\u5378\u8f7dPython\u5e76\u6e05\u7406\u6b8b\u7559\u6587\u4ef6\u3002\u65e0\u8bba\u662f\u5728Windows\u3001macOS\u8fd8\u662fLinux\u7cfb\u7edf\u4e0a\uff0c\u6309\u7167\u6b65\u9aa4\u64cd\u4f5c\u5747\u80fd\u786e\u4fdd\u5378\u8f7d\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5224\u65ad\u6211\u662f\u5426\u5b89\u88c5\u4e86Python\uff1f<\/strong><br \/>\u8981\u786e\u8ba4\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684\u7248\u672c\u3002\u5982\u679c\u663e\u793a\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u53cd\u9988\u6216\u63d0\u793a\uff0c\u5219\u53ef\u80fd\u672a\u5b89\u88c5Python\u3002<\/p>\n<p><strong>\u5378\u8f7dPython\u4f1a\u5f71\u54cd\u5230\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u5417\uff1f<\/strong><br \/>\u5378\u8f7dPython\u53ef\u80fd\u4f1a\u5f71\u54cd\u90a3\u4e9b\u4f9d\u8d56\u4e8ePython\u7684\u5e94\u7528\u7a0b\u5e8f\u6216\u5e93\u3002\u5982\u679c\u60a8\u5728\u7cfb\u7edf\u4e2d\u4f7f\u7528\u4e86\u4e00\u4e9b\u57fa\u4e8ePython\u5f00\u53d1\u7684\u8f6f\u4ef6\uff0c\u5efa\u8bae\u5728\u5378\u8f7d\u4e4b\u524d\u786e\u8ba4\u8fd9\u4e9b\u8f6f\u4ef6\u662f\u5426\u80fd\u72ec\u7acb\u8fd0\u884c\u6216\u662f\u5426\u6709\u66ff\u4ee3\u65b9\u6848\u3002<\/p>\n<p><strong>\u5982\u4f55\u786e\u4fdd\u5e72\u51c0\u5378\u8f7dPython\uff1f<\/strong><br \/>\u4e3a\u4e86\u786e\u4fdd\u5e72\u51c0\u5378\u8f7dPython\uff0c\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u7684\u5378\u8f7d\u5de5\u5177\u8fdb\u884c\u64cd\u4f5c\uff0c\u53e6\u5916\uff0c\u5efa\u8bae\u624b\u52a8\u5220\u9664Python\u5b89\u88c5\u76ee\u5f55\u548c\u76f8\u5173\u73af\u5883\u53d8\u91cf\u3002\u68c0\u67e5\u7528\u6237\u76ee\u5f55\u4e0b\u7684<code>.py<\/code>\u6216<code>.python<\/code>\u6587\u4ef6\u5939\uff0c\u786e\u4fdd\u6ca1\u6709\u6b8b\u7559\u6587\u4ef6\u3002\u540c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u6ce8\u518c\u8868\u6e05\u7406\u5de5\u5177\u6765\u5220\u9664\u53ef\u80fd\u7684\u6ce8\u518c\u8868\u9879\uff0c\u4ee5\u9632\u6b62\u5c06\u6765\u91cd\u65b0\u5b89\u88c5\u65f6\u51fa\u73b0\u51b2\u7a81\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5378\u8f7d\u539f\u6765\u7684Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u8fdb\u884c\uff1a\u9996\u5148\uff0c\u4f7f\u7528\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177\u5378\u8f7d\u3001\u5176\u6b21\uff0c\u5220\u9664\u6b8b\u7559\u6587\u4ef6\u548c\u73af\u5883\u53d8\u91cf\u3001 [&hellip;]","protected":false},"author":3,"featured_media":997644,"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\/997628"}],"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=997628"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/997628\/revisions"}],"predecessor-version":[{"id":997647,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/997628\/revisions\/997647"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/997644"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=997628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=997628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=997628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}