{"id":944387,"date":"2024-12-26T23:05:37","date_gmt":"2024-12-26T15:05:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/944387.html"},"modified":"2024-12-26T23:05:39","modified_gmt":"2024-12-26T15:05:39","slug":"macbook%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/944387.html","title":{"rendered":"macbook\u5982\u4f55\u8fd0\u884cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25081411\/f10c7f5e-2db7-4fae-8bcc-13b1cb0cf5c8.webp\" alt=\"macbook\u5982\u4f55\u8fd0\u884cpython\" \/><\/p>\n<p><p> \u8981\u5728MacBook\u4e0a\u8fd0\u884cPython\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a<strong>\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u7ec8\u7aef\u8fd0\u884cPython\u3001\u5b89\u88c5\u548c\u4f7f\u7528IDE<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u786e\u4fdd\u4f60\u7684MacBook\u4e0a\u5b89\u88c5\u4e86Python\u3002\u5c3d\u7ba1macOS\u7cfb\u7edf\u81ea\u5e26\u6709Python 2.x\u7248\u672c\uff0c\u4f46\u4e3a\u4e86\u4f7f\u7528\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u66f4\u65b0\uff0c\u5efa\u8bae\u5b89\u88c5Python 3.x\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Homebrew\u5b89\u88c5Python<\/h4>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u4e00\u4e2a\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\uff08Terminal\uff09\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Homebrew\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<\/li>\n<li>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528Homebrew\u5b89\u88c5Python 3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u4ecePython\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305<\/h4>\n<\/p>\n<ul>\n<li>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff1a<a href=\"https:\/\/www.python.org\/\">Python.org<\/a>\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8emacOS\u7684\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002<\/li>\n<li>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u5b89\u88c5\u5305\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u5e38Python\u548cpip\uff08Python\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff09\u4f1a\u81ea\u52a8\u914d\u7f6e\u5230\u7cfb\u7edf\u8def\u5f84\u4e2d\uff0c\u4f46\u4e3a\u4e86\u786e\u4fdd\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u76f4\u63a5\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u53ef\u4ee5\u624b\u52a8\u68c0\u67e5\u548c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770bPython\u7248\u672c\uff0c\u786e\u4fdd\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5pip\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u5982\u679c\u4e0a\u8ff0\u547d\u4ee4\u8fd4\u56dePython\u548cpip\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u548c\u914d\u7f6e\u6210\u529f\u3002\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u624b\u52a8\u7f16\u8f91<code>.bash_profile<\/code>\u6216<code>.zshrc<\/code>\u6587\u4ef6\uff08\u6839\u636e\u4f60\u4f7f\u7528\u7684shell\uff09\u6765\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u7ec8\u7aef\u8fd0\u884cPython<\/h3>\n<\/p>\n<p><h4>1. \u76f4\u63a5\u8fd0\u884cPython\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/h4>\n<\/p>\n<ul>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python3<\/code>\uff0c\u4f1a\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u6267\u884c\u3002<\/li>\n<\/ul>\n<p><h4>2. \u8fd0\u884cPython\u811a\u672c\u6587\u4ef6<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u521b\u5efa\u4e00\u4e2aPython\u6587\u4ef6\uff0c\u4f8b\u5982<code>hello.py<\/code>\uff0c\u5728\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884cPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u5b89\u88c5\u548c\u4f7f\u7528IDE<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u9ad8\u6548\u5730\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528IDE\uff08\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u3002\u5e38\u7528\u7684Python\u5f00\u53d1\u73af\u5883\u5305\u62ecPyCharm\u3001Visual Studio Code\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5PyCharm<\/h4>\n<\/p>\n<ul>\n<li>\u524d\u5f80JetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5b98\u7f51\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5PyCharm\u793e\u533a\u7248\u6216\u4e13\u4e1a\u7248\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u542f\u52a8PyCharm\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u9879\u76ee\u3002<\/li>\n<li>\u914d\u7f6e\u9879\u76ee\u7684Python\u89e3\u91ca\u5668\uff0c\u786e\u4fdd\u9009\u62e9\u5b89\u88c5\u7684Python 3\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><h4>2. \u4f7f\u7528Visual Studio Code<\/h4>\n<\/p>\n<ul>\n<li>\u524d\u5f80Visual Studio Code\u5b98\u7f51\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5VS Code\u3002<\/li>\n<li>\u542f\u52a8VS Code\uff0c\u5b89\u88c5Python\u6269\u5c55\u63d2\u4ef6\uff0c\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/li>\n<li>\u521b\u5efa\u5e76\u6253\u5f00Python\u6587\u4ef6\uff0c\u786e\u4fdd\u9009\u62e9\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u7ba1\u7406Python\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u5e38\u9700\u8981\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u548c\u6a21\u5757\uff0cpip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406\u8fd9\u4e9b\u5e93\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528pip\u5b89\u88c5\u5305<\/h4>\n<\/p>\n<ul>\n<li>\n<p>\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528pip\u5b89\u88c5Python\u5305\uff0c\u4f8b\u5982\u5b89\u88c5<code>requests<\/code>\u5e93\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>\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><h4>2. \u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5305<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u5305\u7248\u672c\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\u5de5\u5177\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u6fc0\u6d3b\u72b6\u6001\u4e0b\uff0c\u4f7f\u7528pip\u5b89\u88c5\u7684\u5305\u4ec5\u5bf9\u5f53\u524d\u865a\u62df\u73af\u5883\u6709\u6548\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u8c03\u8bd5\u548c\u4f18\u5316Python\u4ee3\u7801<\/h3>\n<\/p>\n<p><h4>1. \u4f7f\u7528\u8c03\u8bd5\u5de5\u5177<\/h4>\n<\/p>\n<p><p>IDE\u901a\u5e38\u63d0\u4f9b\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u4f8b\u5982\u65ad\u70b9\u8c03\u8bd5\u3001\u53d8\u91cf\u76d1\u89c6\u7b49\u3002PyCharm\u548cVS Code\u90fd\u652f\u6301\u65ad\u70b9\u8c03\u8bd5\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0c\u9010\u6b65\u6267\u884c\u4ee3\u7801\u67e5\u770b\u8fd0\u884c\u72b6\u6001\u548c\u53d8\u91cf\u503c\u3002<\/p>\n<\/p>\n<p><h4>2. \u6027\u80fd\u4f18\u5316<\/h4>\n<\/p>\n<p><p>Python\u4ee3\u7801\u7684\u6027\u80fd\u4f18\u5316\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u548c\u5e93<\/strong>\uff1aPython\u7684\u5185\u7f6e\u51fd\u6570\u548c\u5e93\u901a\u5e38\u7ecf\u8fc7\u9ad8\u5ea6\u4f18\u5316\uff0c\u80fd\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u3002<\/li>\n<li><strong>\u4f7f\u7528\u751f\u6210\u5668\u548c\u8fed\u4ee3\u5668<\/strong>\uff1a\u751f\u6210\u5668\u548c\u8fed\u4ee3\u5668\u53ef\u4ee5\u8282\u7701\u5185\u5b58\uff0c\u63d0\u9ad8\u6548\u7387\u3002<\/li>\n<li><strong>\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b<\/strong>\uff1a\u5bf9\u4e8eI\/O\u5bc6\u96c6\u578b\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6765\u63d0\u5347\u6027\u80fd\u3002<\/li>\n<li><strong>\u5256\u6790\u4ee3\u7801<\/strong>\uff1a\u4f7f\u7528<code>cProfile<\/code>\u6a21\u5757\u53ef\u4ee5\u5206\u6790\u4ee3\u7801\u7684\u6027\u80fd\u74f6\u9888\uff0c\u8fdb\u884c\u9488\u5bf9\u6027\u7684\u4f18\u5316\u3002<\/li>\n<\/ul>\n<p><h3>\u4e03\u3001\u5b66\u4e60\u548c\u63d0\u5347Python\u6280\u80fd<\/h3>\n<\/p>\n<p><h4>1. \u5728\u7ebf\u5b66\u4e60\u8d44\u6e90<\/h4>\n<\/p>\n<ul>\n<li><strong>\u5b98\u65b9\u7f51\u7ad9\u6587\u6863<\/strong>\uff1aPython\u7684\u5b98\u65b9\u6587\u6863\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u8bed\u8a00\u7684\u4f7f\u7528\u548c\u6807\u51c6\u5e93\uff0c\u9002\u5408\u7cfb\u7edf\u5b66\u4e60\u3002<\/li>\n<li><strong>\u5728\u7ebf\u8bfe\u7a0b<\/strong>\uff1aCoursera\u3001Udemy\u7b49\u5e73\u53f0\u63d0\u4f9bPython\u76f8\u5173\u7684\u5728\u7ebf\u8bfe\u7a0b\uff0c\u6db5\u76d6\u57fa\u7840\u5230\u9ad8\u7ea7\u4e3b\u9898\u3002<\/li>\n<\/ul>\n<p><h4>2. \u53c2\u4e0e\u5f00\u6e90\u9879\u76ee<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u53c2\u4e0e\u5f00\u6e90\u9879\u76ee\uff0c\u53ef\u4ee5\u63d0\u9ad8\u5b9e\u6218\u80fd\u529b\uff0c\u6df1\u5165\u7406\u89e3Python\u7684\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>3. \u52a0\u5165\u793e\u533a<\/h4>\n<\/p>\n<p><p>\u53c2\u4e0ePython\u76f8\u5173\u7684\u793e\u533a\u548c\u8bba\u575b\uff0c\u4ea4\u6d41\u7ecf\u9a8c\uff0c\u83b7\u53d6\u5e2e\u52a9\u3002\u4f8b\u5982\uff0cReddit\u7684Python\u793e\u533a\u3001Stack Overflow\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728MacBook\u4e0a\u8fd0\u884cPython\u7684\u8fc7\u7a0b\u6d89\u53ca\u5b89\u88c5\u3001\u914d\u7f6e\u3001\u8fd0\u884c\u548c\u5b66\u4e60\u591a\u4e2a\u65b9\u9762\u3002<strong>\u901a\u8fc7\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u3001\u4f7f\u7528\u7ec8\u7aef\u548cIDE\u8fdb\u884c\u5f00\u53d1\u3001\u7ba1\u7406\u5305\u548c\u73af\u5883\u3001\u8c03\u8bd5\u4f18\u5316\u4ee3\u7801\u3001\u4ee5\u53ca\u4e0d\u65ad\u5b66\u4e60\u548c\u5b9e\u8df5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u9ad8Python\u5f00\u53d1\u6280\u80fd<\/strong>\u3002\u501f\u52a9MacBook\u7684\u7a33\u5b9a\u6027\u80fd\u548c\u751f\u6001\u7cfb\u7edf\uff0cPython\u5f00\u53d1\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u548c\u4fbf\u6377\u3002\u5e0c\u671b\u672c\u6307\u5357\u80fd\u591f\u5e2e\u52a9\u4f60\u987a\u5229\u5728MacBook\u4e0a\u8fd0\u884c\u548c\u5f00\u53d1Python\u5e94\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728MacBook\u4e0a\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728MacBook\u4e0a\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u5927\u90e8\u5206Mac\u7cfb\u7edf\u5df2\u7ecf\u9884\u88c5\u4e86Python 2.x\u7248\u672c\uff0c\u4f46\u5efa\u8bae\u7528\u6237\u5b89\u88c5\u6700\u65b0\u7684Python 3.x\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eePython\u5b98\u7f51\uff08python.org\uff09\u4e0b\u8f7d\u9002\u5408Mac\u7684\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u6b64\u5916\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528Homebrew\uff0c\u8fd9\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165<code>brew install python<\/code>\u6765\u5b89\u88c5Python\u3002<\/p>\n<p><strong>\u5728MacBook\u4e0a\u5982\u4f55\u521b\u5efa\u548c\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u521b\u5efa\u548c\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\u4e5f\u5f88\u7b80\u5355\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982TextEdit\u6216VS Code\uff09\u6765\u7f16\u5199Python\u4ee3\u7801\u3002\u5c06\u6587\u4ef6\u4fdd\u5b58\u4e3a<code>.py<\/code>\u683c\u5f0f\uff0c\u4f8b\u5982<code>hello.py<\/code>\u3002\u8981\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u811a\u672c\uff0c\u53ea\u9700\u6253\u5f00\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u8f93\u5165<code>python3 hello.py<\/code>\u5e76\u6309\u56de\u8f66\u952e\u5373\u53ef\u6267\u884c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728MacBook\u4e0a\u4f7f\u7528Python\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u4f7f\u7528\u865a\u62df\u73af\u5883\u662f\u7ba1\u7406Python\u9879\u76ee\u4f9d\u8d56\u7684\u6700\u4f73\u5b9e\u8df5\u3002\u5728MacBook\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165<code>python3 -m venv myenv<\/code>\u6765\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u73af\u5883\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>source myenv\/bin\/activate<\/code>\uff0c\u8fd9\u5c06\u4f7f\u60a8\u80fd\u591f\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u8fd0\u884c\u7279\u5b9a\u9879\u76ee\u6240\u9700\u7684\u5e93\uff0c\u786e\u4fdd\u4f9d\u8d56\u9879\u4e4b\u95f4\u4e0d\u4f1a\u4ea7\u751f\u51b2\u7a81\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728MacBook\u4e0a\u8fd0\u884cPython\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5b89\u88c5Python\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u7ec8\u7aef\u8fd0\u884cPytho [&hellip;]","protected":false},"author":3,"featured_media":944391,"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\/944387"}],"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=944387"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/944387\/revisions"}],"predecessor-version":[{"id":944393,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/944387\/revisions\/944393"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/944391"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=944387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=944387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=944387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}