{"id":1284,"date":"2025-07-30T16:28:00","date_gmt":"2025-07-30T08:28:00","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=1284"},"modified":"2025-07-30T16:28:00","modified_gmt":"2025-07-30T08:28:00","slug":"%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5mac-python3%e7%8e%af%e5%a2%83%e9%97%ae%e9%a2%98%e5%8f%8a%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/1284.html","title":{"rendered":"\u5982\u4f55\u6392\u67e5mac python3\u73af\u5883\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848\u6307\u5357"},"content":{"rendered":"<p><h>\u5982\u4f55\u6392\u67e5Mac\u4e0aPython 3\u7684\u95ee\u9898<\/h><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/7kHi356Gh.jpg\" alt=\"\u5982\u4f55\u6392\u67e5mac python3\u73af\u5883\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848\u6307\u5357\" title=\"\u5982\u4f55\u6392\u67e5mac python3\u73af\u5883\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848\u6307\u5357\"><\/p>\n<p><p>\u5728Mac\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u4f7f\u7528Python 3\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u95ee\u9898\uff0c\u5982\u5b89\u88c5\u5931\u8d25\u3001\u8fd0\u884c\u9519\u8bef\u7b49\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6392\u67e5\u6307\u5357\uff0c\u5e2e\u52a9\u60a8\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h2>1. \u786e\u8ba4Python 3\u662f\u5426\u5df2\u5b89\u88c5<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u6392\u67e5\u95ee\u9898\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u8ba4Python 3\u662f\u5426\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u68c0\u67e5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u8f93\u5165\u547d\u4ee4 `python3 &#8211;version` \u5e76\u6309\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5982\u679c\u7cfb\u7edf\u8fd4\u56dePython 3\u7684\u7248\u672c\u4fe1\u606f\uff0c\u8bf4\u660ePython 3\u5df2\u5b89\u88c5\u3002<\/li>\n<li>\u5982\u679c\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\uff0c\u8bf4\u660ePython 3\u672a\u5b89\u88c5\u6216\u5b89\u88c5\u8def\u5f84\u4e0d\u6b63\u786e\u3002<\/li>\n<\/ol>\n<p><h2>2. \u68c0\u67e5Python 3\u7684\u5b89\u88c5\u8def\u5f84<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u786e\u8ba4Python 3\u5df2\u5b89\u88c5\uff0c\u4f46\u4ecd\u7136\u9047\u5230\u95ee\u9898\uff0c\u90a3\u4e48\u53ef\u80fd\u662fPython 3\u7684\u5b89\u88c5\u8def\u5f84\u4e0d\u6b63\u786e\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u68c0\u67e5Python 3\u7684\u5b89\u88c5\u8def\u5f84\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 `which python3`\u3002<\/li>\n<li>\u5982\u679c\u8fd4\u56de\u4e00\u4e2a\u8def\u5f84\uff0c\u6bd4\u5982 `\/usr\/local\/bin\/python3`\uff0c\u90a3\u4e48\u8fd9\u5c31\u662fPython 3\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<li>\u5982\u679c\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\u6216\u65e0\u8f93\u51fa\uff0c\u8bf4\u660ePython 3\u7684\u5b89\u88c5\u8def\u5f84\u53ef\u80fd\u4e0d\u6b63\u786e\u3002<\/li>\n<\/ol>\n<p><h2>3. \u68c0\u67e5Python 3\u7684\u6743\u9650\u95ee\u9898<\/h2>\n<\/p>\n<p><p>\u6709\u65f6\uff0cPython 3\u53ef\u80fd\u7531\u4e8e\u6743\u9650\u95ee\u9898\u800c\u65e0\u6cd5\u6b63\u5e38\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u68c0\u67e5\u548c\u89e3\u51b3\u6743\u9650\u95ee\u9898\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5c1d\u8bd5\u8fd0\u884c\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\uff0c\u5982 `python3 -c &#8220;print(&#8216;Hello, world!&#8217;)&#8221;`\u3002<\/li>\n<li>\u5982\u679c\u811a\u672c\u65e0\u6cd5\u8fd0\u884c\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u6ca1\u6709\u6267\u884c\u6743\u9650\u3002<\/li>\n<li>\u4f7f\u7528 `chmod +x script.py` \u547d\u4ee4\u4e3a\u811a\u672c\u6dfb\u52a0\u6267\u884c\u6743\u9650\u3002<\/li>\n<li>\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u53ef\u80fd\u662fPython 3\u7684\u5b89\u88c5\u8def\u5f84\u5b58\u5728\u6743\u9650\u95ee\u9898\u3002<\/li>\n<\/ol>\n<p><h2>4. \u66f4\u65b0Python 3\u548cpip<\/h2>\n<\/p>\n<p><p>\u786e\u4fddPython 3\u548cpip\uff08Python\u7684\u5305\u7ba1\u7406\u5668\uff09\u90fd\u662f\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u89e3\u51b3\u4e00\u4e9b\u5df2\u77e5\u7684\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u66f4\u65b0Python 3\u548cpip\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5bf9\u4e8e\u4f7f\u7528Homebrew\u5b89\u88c5\u7684Python 3\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\uff1a`brew upgrade python3`\u3002<\/li>\n<li>\u5bf9\u4e8e\u5176\u4ed6\u5b89\u88c5\u65b9\u5f0f\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u66f4\u65b0\u3002<\/li>\n<li>\u66f4\u65b0pip\uff1a`python3 -m pip install &#8211;upgrade pip`\u3002<\/li>\n<\/ol>\n<p><h2>5. \u68c0\u67e5Python 3\u7684\u4f9d\u8d56\u5e93<\/h2>\n<\/p>\n<p><p>\u67d0\u4e9bPython\u811a\u672c\u53ef\u80fd\u4f9d\u8d56\u4e8e\u7279\u5b9a\u7684\u5e93\u3002\u5982\u679c\u811a\u672c\u8fd0\u884c\u65f6\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u7f3a\u5c11\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u68c0\u67e5\u548c\u5b89\u88c5\u4f9d\u8d56\u5e93\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u811a\u672c\uff0c\u5e76\u6ce8\u610f\u9519\u8bef\u4fe1\u606f\u4e2d\u63d0\u5230\u7684\u4f9d\u8d56\u5e93\u3002<\/li>\n<li>\u4f7f\u7528pip\u5b89\u88c5\u7f3a\u5931\u7684\u5e93\uff1a`pip3 install \u5e93\u540d`\u3002<\/li>\n<li>\u5982\u679c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u6216\u6743\u9650\u95ee\u9898\u3002<\/li>\n<\/ol>\n<p><h2>6. \u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u521b\u5efa\u548c\u4f7f\u7528\u865a\u62df\u73af\u5883\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5virtualenv\uff1a`pip3 install virtualenv`\u3002<\/li>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a`virtualenv myenv`\u3002<\/li>\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a`source myenv\/bin\/activate`\u3002<\/li>\n<li>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u5305\uff1a`pip install \u5305\u540d`\u3002<\/li>\n<\/ol>\n<p><h2>7. \u67e5\u770b\u5b98\u65b9\u6587\u6863\u548c\u793e\u533a\u652f\u6301<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u4ee5\u4e0a\u6b65\u9aa4\u90fd\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u5efa\u8bae\u67e5\u770bPython 3\u7684\u5b98\u65b9\u6587\u6863\u6216\u5bfb\u6c42\u793e\u533a\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6709\u7528\u7684\u8d44\u6e90\uff1a<\/p>\n<\/p>\n<ul>\n<li>Python 3\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/docs.python.org\/3\/<\/li>\n<li>Stack Overflow\uff1ahttps:\/\/stackoverflow.com\/<\/li>\n<li>Python\u5b98\u65b9\u90ae\u4ef6\u5217\u8868\uff1ahttps:\/\/mail.python.org\/mailman\/listinfo\/python-list<\/li>\n<\/ul>\n<p><h3>\u95ee\u7b54\u73af\u8282<\/h3>\n<\/p>\n<p><b>\u95ee\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684Python 3\u811a\u672c\u8fd0\u884c\u65f6\u603b\u662f\u51fa\u73b0\u6743\u9650\u9519\u8bef\uff1f<\/b><\/p>\n<p><p>\u7b54\uff1a\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3aPython 3\u7684\u5b89\u88c5\u8def\u5f84\u6ca1\u6709\u6267\u884c\u6743\u9650\uff0c\u6216\u8005\u811a\u672c\u672c\u8eab\u6ca1\u6709\u6267\u884c\u6743\u9650\u3002\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 `chmod +x script.py` \u4e3a\u811a\u672c\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff0c\u6216\u8005\u68c0\u67e5Python 3\u7684\u5b89\u88c5\u8def\u5f84\u662f\u5426\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><b>\u95ee\uff1a\u6211\u66f4\u65b0\u4e86Python 3\u548cpip\uff0c\u4f46\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u600e\u4e48\u529e\uff1f<\/b><\/p>\n<p><p>\u7b54\uff1a\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5Python 3\u548cpip\u3002\u5bf9\u4e8e\u4f7f\u7528Homebrew\u5b89\u88c5\u7684Python 3\uff0c\u53ef\u4ee5\u4f7f\u7528 `brew uninstall python3` \u548c `brew install python3` \u6765\u91cd\u65b0\u5b89\u88c5\u3002\u5bf9\u4e8e\u5176\u4ed6\u5b89\u88c5\u65b9\u5f0f\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><b>\u95ee\uff1a\u6211\u5b89\u88c5\u4e86\u4f9d\u8d56\u5e93\uff0c\u4f46\u811a\u672c\u4ecd\u7136\u65e0\u6cd5\u8fd0\u884c\uff0c\u4e3a\u4ec0\u4e48\uff1f<\/b><\/p>\n<p><p>\u7b54\uff1a\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a\u4f9d\u8d56\u5e93\u7684\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u6216\u8005\u4f9d\u8d56\u5e93\u7684\u5b89\u88c5\u8def\u5f84\u4e0d\u6b63\u786e\u3002\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 `pip3 show \u5e93\u540d` \u67e5\u770b\u4f9d\u8d56\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u9700\u8981\u5b89\u88c5\u6216\u66f4\u65b0\u5176\u4ed6\u4f9d\u8d56\u5e93\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u6392\u67e5Mac\u4e0aPython 3\u7684\u95ee\u9898 \u5728Mac\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u4f7f\u7528Python 3\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u95ee\u9898\uff0c\u5982\u5b89\u88c5\u5931\u8d25\u3001\u8fd0\u884c\u9519\u8bef\u7b49\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6392\u67e5\u6307\u5357\uff0c\u5e2e\u52a9\u60a8\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002 1. \u786e\u8ba4Python 3\u662f\u5426\u5df2\u5b89\u88c5 \u5728\u5f00\u59cb\u6392\u67e5\u95ee\u9898\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u8ba4&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1285,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[134,47,505],"topic":[],"class_list":["post-1284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-python","tag-47","tag-505"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=1284"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1284\/revisions"}],"predecessor-version":[{"id":1287,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1284\/revisions\/1287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/1285"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=1284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=1284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=1284"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=1284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}