{"id":205239,"date":"2025-05-29T09:19:23","date_gmt":"2025-05-29T01:19:23","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205239\/"},"modified":"2025-05-29T09:19:23","modified_gmt":"2025-05-29T01:19:23","slug":"%e9%94%99%e8%af%af%ef%bc%9apython-%e5%8c%85%e5%ae%89%e8%a3%85%e6%97%b6%e7%9a%84%e5%a4%96%e9%83%a8%e7%ae%a1%e7%90%86%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205239\/","title":{"rendered":"\u9519\u8bef\uff1apython \u5305\u5b89\u88c5\u65f6\u7684\u5916\u90e8\u7ba1\u7406\u73af\u5883"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u9519\u8bef\uff1apython \u5305\u5b89\u88c5\u65f6\u7684\u5916\u90e8\u7ba1\u7406\u73af\u5883<\/h1>\n<p>\u6765\u5230\u7684\u5927\u5bb6\uff0c\u76f8\u4fe1\u90fd\u662f\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5e0c\u671b\u5728\u8fd9\u91cc\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u7f16\u7a0b\u77e5\u8bc6\u3002\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u5e26\u5927\u5bb6\u804a\u804a\u300a\u9519\u8bef\uff1apython \u5305\u5b89\u88c5\u65f6\u7684\u5916\u90e8\u7ba1\u7406\u73af\u5883\u300b\uff0c\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p>\u6211\u5c1d\u8bd5\u4f7f\u7528\u6b64\u547d\u4ee4\u5b89\u88c5 python \u5305\u3002<\/p>\n<pre>pip3 install [package-name]\n<\/pre>\n<p>\u7136\u540e\u629b\u51fa\u4e86\u8fd9\u4e2a\u9519\u8bef\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241126\/17326307176745d8bd70883.jpg\" style=\"max-width:100%\" class=\"aligncenter\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241126\/17326307196745d8bf936fc.jpg\" class=\"aligncenter\"><\/p>\n<ul>\n<li>\u5728\u5355\u4e2a macos \u673a\u5668\u4e2d\u4f7f\u7528\u4e24\u79cd\u7c7b\u578b\u7684 python &#8211; \u7528\u6237\u7279\u5b9a\u7684\u5305\u548c\u7cfb\u7edf\u8303\u56f4\u7684\u5305\u3002<\/li>\n<li>\u7cfb\u7edf\u8303\u56f4\u7684\u5305\u7531\u6240\u6709\u7528\u6237\u5171\u4eab\uff0c\u751a\u81f3<strong>\u50cfapt<\/strong>\u8fd9\u6837\u7684\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3002\u5c06\u7528\u6237\u7279\u5b9a\u7684\u5305\u5b89\u88c5\u4e3a\u7cfb\u7edf\u8303\u56f4\u7684\u5305\u662f\u975e\u5e38\u5371\u9669\u7684\uff0c\u56e0\u4e3a\u5982\u679c\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u8fd0\u884c\u4e00\u4e9b python \u811a\u672c\uff0c\u5b83\u53ef\u80fd\u4f1a\u4e0e\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u53d1\u751f\u51b2\u7a81\u3002<\/li>\n<\/ul>\n<ol>\n<li>\n<p>\u521b\u5efa path\/.config\/pip\/pip.conf \u5e76\u8f93\u5165\u6b64\u811a\u672c\u3002<\/p>\n<pre>[global]\nbreak-system-packages = true\nuser = true\n<\/pre>\n<\/li>\n<li>\n<p>\u5b89\u88c5 pipelinev \u6765\u7ba1\u7406\u6bcf\u4e2a\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002 pip.conf \u6587\u4ef6\u5141\u8bb8\u547d\u4ee4\u4f7f\u7528 &#8211;break-system-packages \u548c &#8211;user \u9009\u9879\u8fd0\u884c\u3002<\/p>\n<pre>pip3 install pipenv\n<\/pre>\n<\/li>\n<li>\n<p>\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884c\u5305\u542b\u6240\u6709\u9879\u76ee\u4f9d\u8d56\u9879\u7684\u6587\u4ef6<\/p>\n<pre>pipenv run python [file-name] .py\n<\/pre>\n<\/li>\n<li>\n<p>\u5426\u5219\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c\u865a\u62df\u73af\u5883\u5b9e\u4f8b\u5e76\u8fd0\u884c python \u6587\u4ef6\u3002<\/p>\n<pre>pipenv shell\npython [file-name].py\n<\/pre>\n<\/li>\n<\/ol>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u9519\u8bef\uff1apython \u5305\u5b89\u88c5\u65f6\u7684\u5916\u90e8\u7ba1\u7406\u73af\u5883\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9519\u8bef\uff1apython \u5305\u5b89\u88c5\u65f6\u7684\u5916&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-205239","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=205239"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205239\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}