{"id":941641,"date":"2024-12-26T21:39:33","date_gmt":"2024-12-26T13:39:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/941641.html"},"modified":"2024-12-26T21:39:35","modified_gmt":"2024-12-26T13:39:35","slug":"mac-%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aepython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/941641.html","title":{"rendered":"mac \u5982\u4f55\u914d\u7f6epython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25075739\/c55c7c91-a167-4795-a529-8b0a5d9370bb.webp\" alt=\"mac \u5982\u4f55\u914d\u7f6epython\" \/><\/p>\n<p><p> <strong>\u914d\u7f6eMac\u4ee5\u4f7f\u7528Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u5b89\u88c5Homebrew\u3001\u4f7f\u7528Homebrew\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff08\u5982virtualenv\uff09<\/strong>\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684\u4e00\u4e2a\u6b65\u9aa4\uff1a<strong>\u5b89\u88c5Homebrew<\/strong>\u3002Homebrew\u662fMacOS\u4e0a\u7684\u4e00\u4e2a\u5305\u7ba1\u7406\u5668\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8f7b\u677e\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\u3002\u8981\u5b89\u88c5Homebrew\uff0c\u4f60\u9700\u8981\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/code>\u3002\u8fd9\u5c06\u4e0b\u8f7d\u5e76\u8fd0\u884cHomebrew\u7684\u5b89\u88c5\u811a\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>brew --version<\/code>\u6765\u9a8c\u8bc1Homebrew\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u4e00\u3001\u5b89\u88c5Homebrew<\/p>\n<\/p>\n<p><p>Homebrew\u662fMacOS\u4e0a\u6700\u53d7\u6b22\u8fce\u7684\u5305\u7ba1\u7406\u5668\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u7b80\u5316\u8f6f\u4ef6\u5305\u7684\u5b89\u88c5\u548c\u7ba1\u7406\u8fc7\u7a0b\u3002\u901a\u8fc7Homebrew\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5Python\u4ee5\u53ca\u5176\u76f8\u5173\u7684\u5de5\u5177\u548c\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d\u5e76\u5b89\u88c5Homebrew<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fd9\u5c06\u4e0b\u8f7d\u5e76\u8fd0\u884cHomebrew\u7684\u5b89\u88c5\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\uff0c\u5e76\u53ef\u80fd\u8981\u6c42\u4f60\u8f93\u5165\u7ba1\u7406\u5458\u5bc6\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>brew --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1Homebrew\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u8be5\u547d\u4ee4\u5c06\u8f93\u51faHomebrew\u7684\u5f53\u524d\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528Homebrew\u5b89\u88c5Python<\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u5b89\u88c5\u4e86Homebrew\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u5b89\u88c5Python\u3002Homebrew\u63d0\u4f9b\u4e86\u6700\u65b0\u7684Python\u7248\u672c\uff0c\u5e76\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u7ba1\u7406\u548c\u66f4\u65b0\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5b89\u88c5Python\u4ee5\u53capip\uff08Python\u7684\u5305\u7ba1\u7406\u5668\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 --version<\/code>\u548c<code>pip3 --version<\/code>\u6765\u9a8c\u8bc1Python\u548cpip\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u8fd9\u4e9b\u547d\u4ee4\u5c06\u8f93\u51faPython\u548cpip\u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u4e3a\u4e86\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u80fd\u591f\u6b63\u786e\u627e\u5230Python\u548cpip\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cHomebrew\u4f1a\u81ea\u52a8\u914d\u7f6e\u8fd9\u4e9b\u53d8\u91cf\uff0c\u4f46\u4f60\u53ef\u80fd\u9700\u8981\u624b\u52a8\u68c0\u67e5\u548c\u914d\u7f6e\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u8f91shell\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a\u53d6\u51b3\u4e8e\u4f60\u4f7f\u7528\u7684shell\uff08\u5982bash\u6216zsh\uff09\uff0c\u4f60\u9700\u8981\u7f16\u8f91\u76f8\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5982<code>~\/.bash_profile<\/code>\u6216<code>~\/.zshrc<\/code>\uff09\u3002\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">nano ~\/.zshrc  # \u5982\u679c\u4f60\u4f7f\u7528zsh<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">nano ~\/.bash_profile  # \u5982\u679c\u4f60\u4f7f\u7528bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0Python\u8def\u5f84<\/strong>\uff1a\u786e\u4fdd\u4ee5\u4e0b\u884c\u5b58\u5728\u4e8e\u6587\u4ef6\u4e2d\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u8bf7\u6dfb\u52a0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/opt\/python\/libexec\/bin:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5237\u65b0\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a\u7f16\u8f91\u5b8c\u6bd5\u540e\uff0c\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5237\u65b0\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source ~\/.zshrc  # \u6216 source ~\/.bash_profile<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u5141\u8bb8\u4f60\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u521b\u5efa\u9694\u79bb\u7684Python\u73af\u5883\uff0c\u4ece\u800c\u907f\u514d\u5305\u51b2\u7a81\u3002<code>virtualenv<\/code>\u548c<code>venv<\/code>\u662f\u4e24\u4e2a\u5e38\u7528\u7684\u865a\u62df\u73af\u5883\u5de5\u5177\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5virtualenv<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5virtualenv\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv venv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5728\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>venv<\/code>\u7684\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u9694\u79bb\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a\u6bcf\u6b21\u5f00\u59cb\u9879\u76ee\u5de5\u4f5c\u65f6\uff0c\u4f60\u9700\u8981\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source venv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u7ec8\u7aef\u63d0\u793a\u7b26\u4f1a\u51fa\u73b0<code>(venv)<\/code>\u5b57\u6837\uff0c\u8868\u793a\u5f53\u524d\u5df2\u5728\u865a\u62df\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684pip\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5305<\/strong>\uff1a\u8981\u5b89\u88c5\u4e00\u4e2aPython\u5305\uff0c\u4f8b\u5982<code>requests<\/code>\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5217\u51fa\u5df2\u5b89\u88c5\u7684\u5305<\/strong>\uff1a\u8981\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e2d\u5df2\u5b89\u88c5\u7684\u6240\u6709\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5378\u8f7d\u5305<\/strong>\uff1a\u8981\u5378\u8f7d\u4e00\u4e2a\u5305\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 uninstall requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7\u5305<\/strong>\uff1a\u8981\u5347\u7ea7\u4e00\u4e2a\u5305\u5230\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install --upgrade requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u4f7f\u7528Python\u5f00\u53d1\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u4e00\u4e9bPython\u5f00\u53d1\u5de5\u5177\uff0c\u5982IDE\u6216\u4ee3\u7801\u7f16\u8f91\u5668\u3002\u8fd9\u4e9b\u5de5\u5177\u63d0\u4f9b\u4e86\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9IDE<\/strong>\uff1a\u4e00\u4e9b\u6d41\u884c\u7684Python IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u548cSublime Text\u3002\u6bcf\u4e2a\u5de5\u5177\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6eIDE<\/strong>\uff1a\u5927\u591a\u6570IDE\u5141\u8bb8\u4f60\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002\u5728\u9879\u76ee\u8bbe\u7f6e\u6216\u504f\u597d\u8bbe\u7f6e\u4e2d\uff0c\u5c06Python\u89e3\u91ca\u5668\u8bbe\u7f6e\u4e3a\u4f60\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u6216\u6307\u5411\u4f60\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528IDE\u8c03\u8bd5<\/strong>\uff1a\u501f\u52a9IDE\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u8bbe\u7f6e\u65ad\u70b9\u3001\u68c0\u67e5\u53d8\u91cf\u503c\u3001\u9010\u6b65\u6267\u884c\u4ee3\u7801\u7b49\uff0c\u8fd9\u5bf9\u4e8e\u6392\u67e5\u95ee\u9898\u548c\u4f18\u5316\u4ee3\u7801\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u5b66\u4e60Python\u7f16\u7a0b<\/p>\n<\/p>\n<p><p>\u914d\u7f6e\u597dPython\u73af\u5883\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u5b66\u4e60\u548c\u5b9e\u8df5Python\u7f16\u7a0b\u4e86\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5b66\u4e60Python\u7684\u5efa\u8bae\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728\u7ebf\u6559\u7a0b\u548c\u6587\u6863<\/strong>\uff1aPython\u5b98\u65b9\u6587\u6863\u662f\u5b66\u4e60Python\u7684\u6743\u5a01\u8d44\u6e90\u3002\u6b64\u5916\uff0c\u8bb8\u591a\u5728\u7ebf\u5e73\u53f0\u63d0\u4f9bPython\u6559\u7a0b\uff0c\u5982Codecademy\u3001Coursera\u548cUdemy\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e66\u7c4d<\/strong>\uff1a\u9605\u8bfbPython\u76f8\u5173\u7684\u4e66\u7c4d\uff0c\u5982\u300aPython\u7f16\u7a0b\uff1a\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u548c\u300a\u6d41\u7545\u7684Python\u300b\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u6df1\u5165\u7406\u89e3Python\u7f16\u7a0b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9e\u8df5\u9879\u76ee<\/strong>\uff1a\u901a\u8fc7\u52a8\u624b\u5b9e\u8df5\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u5c06\u6240\u5b66\u7684\u77e5\u8bc6\u5e94\u7528\u5230\u5b9e\u9645\u573a\u666f\u4e2d\u3002\u8fd9\u53ef\u4ee5\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u811a\u672c\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52a0\u5165\u793e\u533a<\/strong>\uff1a\u53c2\u4e0ePython\u793e\u533a\uff0c\u5982Python.org\u8bba\u575b\u3001Reddit\u7684Python\u677f\u5757\uff0c\u4ee5\u53ca\u672c\u5730\u7684Python\u7528\u6237\u7ec4\uff08PUG\uff09\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u4ea4\u6d41\u7ecf\u9a8c\u3001\u89e3\u51b3\u95ee\u9898\uff0c\u5e76\u83b7\u53d6\u65b0\u7684\u5b66\u4e60\u8d44\u6e90\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728Mac\u4e0a\u6210\u529f\u914d\u7f6ePython\u73af\u5883\uff0c\u5e76\u5f00\u59cb\u4f60\u7684Python\u7f16\u7a0b\u4e4b\u65c5\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u4e00\u4e2a\u826f\u597d\u7684\u5f00\u53d1\u73af\u5883\u90fd\u662f\u6210\u529f\u7684\u57fa\u7840\u3002\u5e0c\u671b\u8fd9\u7bc7\u6307\u5357\u80fd\u4e3a\u4f60\u63d0\u4f9b\u5e2e\u52a9\uff0c\u5e76\u795d\u4f60\u5728Python\u5b66\u4e60\u548c\u5f00\u53d1\u4e2d\u53d6\u5f97\u4e30\u7855\u6210\u679c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Mac\u4e0a\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Mac\u4e0a\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002\u4e0b\u8f7d\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u5305\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002\u6b64\u5916\uff0cMac\u81ea\u5e26\u4e86Python 2.x\u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528Python 3.x\u7248\u672c\u4ee5\u83b7\u5f97\u6700\u65b0\u7684\u529f\u80fd\u548c\u652f\u6301\u3002<\/p>\n<p><strong>\u5728Mac\u4e0a\u5982\u4f55\u8bbe\u7f6ePython\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u521b\u5efaPython\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>python3 -m venv myenv<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyenv\u201d\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u53ef\u4ee5\u901a\u8fc7<code>source myenv\/bin\/activate<\/code>\u547d\u4ee4\u5b8c\u6210\u3002\u6fc0\u6d3b\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5305\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Mac\u4e0a\u5b89\u88c5Python\u5e93\uff1f<\/strong><br \/>\u5b89\u88c5Python\u5e93\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\uff0c\u8fd9\u662fPython\u7684\u5305\u7ba1\u7406\u5668\u3002\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u5df2\u6fc0\u6d3b\u540e\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip install package_name<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u4f60\u9700\u8981\u7684\u5e93\uff0c\u4f8b\u5982<code>pip install numpy<\/code>\u3002\u5982\u679c\u4f60\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5728\u547d\u4ee4\u524d\u52a0\u4e0a<code>sudo<\/code>\u4ee5\u83b7\u53d6\u7ba1\u7406\u5458\u6743\u9650\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u914d\u7f6eMac\u4ee5\u4f7f\u7528Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a\u5b89\u88c5Homebrew\u3001\u4f7f\u7528Homebrew\u5b89\u88c5Python\u3001 [&hellip;]","protected":false},"author":3,"featured_media":941643,"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\/941641"}],"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=941641"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/941641\/revisions"}],"predecessor-version":[{"id":941646,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/941641\/revisions\/941646"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/941643"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=941641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=941641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=941641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}