{"id":619,"date":"2025-04-11T21:04:48","date_gmt":"2025-04-11T13:04:48","guid":{"rendered":"http:\/\/blog.heartwarming.online\/?p=619"},"modified":"2025-04-11T21:04:50","modified_gmt":"2025-04-11T13:04:50","slug":"%e5%a6%82%e4%bd%95%e6%ad%a3%e7%a1%ae%e5%8d%87%e7%ba%a7-python-%e7%89%88%e6%9c%ac%ef%bc%88%e9%99%84%e5%b8%b8%e8%a7%81%e6%96%b9%e6%b3%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.heartwarming.online\/index.php\/2025\/04\/11\/%e5%a6%82%e4%bd%95%e6%ad%a3%e7%a1%ae%e5%8d%87%e7%ba%a7-python-%e7%89%88%e6%9c%ac%ef%bc%88%e9%99%84%e5%b8%b8%e8%a7%81%e6%96%b9%e6%b3%95%ef%bc%89\/","title":{"rendered":"\u5982\u4f55\u6b63\u786e\u5347\u7ea7 Python \u7248\u672c\uff08\u9644\u5e38\u89c1\u65b9\u6cd5\uff09"},"content":{"rendered":"\n<p>Python \u7684\u7248\u672c\u5347\u7ea7\u662f\u5f00\u53d1\u8005\u7ef4\u62a4\u5f00\u53d1\u73af\u5883\u7684\u91cd\u8981\u4efb\u52a1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd&nbsp;<strong>\u6b63\u786e\u5347\u7ea7 Python \u7248\u672c\u7684\u65b9\u6cd5<\/strong>\uff0c\u5e76\u6f84\u6e05\u5e38\u89c1\u8bef\u533a\uff08\u5982&nbsp;<code>pip<\/code>&nbsp;\u65e0\u6cd5\u76f4\u63a5\u5347\u7ea7 Python \u89e3\u91ca\u5668\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u68c0\u67e5\u5f53\u524d Python \u7248\u672c<\/h2>\n\n\n\n<p>\u5347\u7ea7\u524d\u9700\u786e\u8ba4\u5f53\u524d\u7248\u672c\u3002\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python --version\n# \u6216\u6307\u5b9a Python 3\uff08\u9002\u7528\u4e8e\u591a\u7248\u672c\u5171\u5b58\u73af\u5883\uff09\npython3 --version<\/pre>\n\n\n\n<p>\u8f93\u51fa\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Python 3.11.1<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u7406\u89e3 pip \u7684\u4f5c\u7528\u4e0e\u9650\u5236<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>pip \u7684\u529f\u80fd<\/strong>\uff1aPython \u5305\u7ba1\u7406\u5668\uff0c\u7528\u4e8e\u5b89\u88c5\/\u5347\u7ea7\u7b2c\u4e09\u65b9\u5e93\uff08\u5982\u00a0<code>requests<\/code>\u3001<code>numpy<\/code>\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5173\u952e\u9650\u5236<\/strong>\uff1a<strong>pip \u65e0\u6cd5\u76f4\u63a5\u5347\u7ea7 Python \u89e3\u91ca\u5668\u672c\u8eab<\/strong>\u3002<br>\u274c \u9519\u8bef\u505a\u6cd5\uff1a<code>pip install --upgrade python<\/code>\uff08\u6b64\u547d\u4ee4\u65e0\u6548\uff09<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u6b63\u786e\u5347\u7ea7 Python \u7684\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u65b9\u6cd5 1\uff1a\u901a\u8fc7\u5b98\u65b9\u5b89\u88c5\u5305\u5347\u7ea7<\/h3>\n\n\n\n<p>\u9002\u7528\u4e8e\u6240\u6709\u64cd\u4f5c\u7cfb\u7edf\uff0c\u624b\u52a8\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u5b89\u88c5\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u8bbf\u95ee\u00a0<a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python \u5b98\u7f51<\/a><\/li>\n\n\n\n<li>\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff08\u5982 Windows \u7684\u00a0<code>.exe<\/code>\uff0cmacOS \u7684\u00a0<code>.pkg<\/code>\uff09<\/li>\n\n\n\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5e76\u52fe\u9009\u00a0<strong>&#8220;Add Python to PATH&#8221;<\/strong>\uff08\u786e\u4fdd\u7ec8\u7aef\u53ef\u8bc6\u522b\u65b0\u7248\u672c\uff09<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\uff08Linux\/macOS\uff09<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">macOS \u901a\u8fc7 Homebrew<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">brew update\nbrew upgrade python<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Ubuntu\/Debian \u901a\u8fc7 apt<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt update\nsudo apt install python3.12  # \u66ff\u6362\u4e3a\u5b9e\u9645\u76ee\u6807\u7248\u672c<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u65b9\u6cd5 3\uff1a\u4f7f\u7528 pyenv\uff08\u591a\u7248\u672c\u7ba1\u7406\u63a8\u8350\uff09<\/h3>\n\n\n\n<p>\u9002\u5408\u9700\u8981\u540c\u65f6\u7ba1\u7406\u591a\u4e2a Python \u7248\u672c\u7684\u5f00\u53d1\u8005\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u5b89\u88c5\u00a0<code>pyenv<\/code>\uff1acurl https:\/\/pyenv.run | bash<\/li>\n\n\n\n<li>\u67e5\u770b\u53ef\u5b89\u88c5\u7248\u672c\uff1apyenv install &#8211;list<\/li>\n\n\n\n<li>\u5b89\u88c5\u6307\u5b9a\u7248\u672c\uff1apyenv install 3.12.0<\/li>\n\n\n\n<li>\u5168\u5c40\u5207\u6362\u7248\u672c\uff1apyenv global 3.12.0<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u9a8c\u8bc1\u5347\u7ea7\u7ed3\u679c<\/h2>\n\n\n\n<p>\u5347\u7ea7\u540e\u91cd\u542f\u7ec8\u7aef\uff0c\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python --version<\/pre>\n\n\n\n<p>\u82e5\u8f93\u51fa\u76ee\u6807\u7248\u672c\uff08\u5982&nbsp;<code>Python 3.12.0<\/code>\uff09\uff0c\u5219\u5347\u7ea7\u6210\u529f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u5347\u7ea7\u540e\u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u865a\u62df\u73af\u5883\u91cd\u5efa<\/strong><br>\u5347\u7ea7 Python \u540e\uff0c\u539f\u6709\u865a\u62df\u73af\u5883\uff08<code>venv<\/code>\u00a0\u6216\u00a0<code>conda<\/code>\uff09\u9700\u91cd\u65b0\u521b\u5efa\uff1abash\u590d\u5236# \u5220\u9664\u65e7\u73af\u5883 rm -rf myenv # \u521b\u5efa\u65b0\u73af\u5883 python -m venv myenv<\/li>\n\n\n\n<li><strong>\u91cd\u88c5\u7b2c\u4e09\u65b9\u5e93<\/strong><br>\u65b0 Python \u73af\u5883\u4e2d\u9700\u91cd\u65b0\u5b89\u88c5\u4f9d\u8d56\uff1abash\u590d\u5236pip install -r requirements.txt<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u7684\u7248\u672c\u5347\u7ea7\u662f\u5f00\u53d1\u8005\u7ef4\u62a4\u5f00\u53d1\u73af\u5883\u7684\u91cd\u8981\u4efb\u52a1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd&nbsp;\u6b63\u786e\u5347\u7ea7 Python \u7248\u672c\u7684\u65b9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":504,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[54,53],"class_list":["post-619","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-pip","tag-python"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.heartwarming.online\/wp-content\/uploads\/2024\/09\/IMG_20240917_205552.jpg","_links":{"self":[{"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":1,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/posts\/619\/revisions\/620"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/media\/504"}],"wp:attachment":[{"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.heartwarming.online\/index.php\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}