{"id":3756,"date":"2025-05-29T23:47:09","date_gmt":"2025-05-29T15:47:09","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=3756"},"modified":"2025-05-29T23:47:09","modified_gmt":"2025-05-29T15:47:09","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85%e7%ac%ac%e4%b8%89%e6%96%b9%e5%ba%93%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/05\/29\/python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85%e7%ac%ac%e4%b8%89%e6%96%b9%e5%ba%93%ef%bc%9f\/","title":{"rendered":"Python\u4e2d\u5982\u4f55\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\uff1f"},"content":{"rendered":"\n<p>\u5728 Python \u4e2d\uff0c<strong>\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93<\/strong>\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 <code>pip<\/code> \u2014\u2014 Python \u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002\u4e0b\u9762\u662f\u6bd4\u8f83\u4e13\u4e1a\u3001\u53ef\u884c\u7684\u5b89\u88c5\u65b9\u5f0f\u53ca\u6392\u67e5\u5efa\u8bae\uff0c\u9002\u5408\u5f00\u53d1\u4e0e\u751f\u4ea7\u73af\u5883\u4f7f\u7528\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\u4f7f\u7528 <code>pip<\/code> \u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\uff08\u6700\u5e38\u89c1\u65b9\u6cd5\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u5b89\u88c5 <code>requests<\/code> \u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install requests<\/code><\/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\u8be6\u7ec6\u6b65\u9aa4\u8bf4\u660e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u786e\u8ba4\u5df2\u5b89\u88c5 <code>pip<\/code><\/h3>\n\n\n\n<p>\u5728\u547d\u4ee4\u884c\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip --version<\/code><\/pre>\n\n\n\n<p>\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip 24.0 from \/usr\/local\/lib\/python3.11\/site-packages\/pip (python 3.11)<\/code><\/pre>\n\n\n\n<p>\u5982\u672a\u5b89\u88c5\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u5b89\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python -m ensurepip --upgrade<\/code><\/pre>\n\n\n\n<p>\u6216\u5728\u67d0\u4e9b\u7cfb\u7edf\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install python3-pip   # Debian \/ Ubuntu\nbrew install python3           # macOS\uff08\u542bpip\uff09<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u5e93<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install numpy==1.24.2<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u4e00\u6b21\u6027\u5b89\u88c5\u591a\u4e2a\u5e93\uff08\u9879\u76ee\u4f9d\u8d56\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install -r requirements.txt<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d <code>requirements.txt<\/code> \u5185\u5bb9\u7c7b\u4f3c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>flask==2.3.3\nsqlalchemy&gt;=1.4.0\nrequests<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5e38\u89c1\u5b89\u88c5\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u95ee\u9898<\/th><th>\u89e3\u51b3\u65b9\u5f0f<\/th><\/tr><\/thead><tbody><tr><td><code>pip<\/code> \u672a\u627e\u5230\u6216\u65e0\u6743\u9650<\/td><td>\u4f7f\u7528 <code>python -m pip install<\/code> \u6216 <code>sudo pip install<\/code><\/td><\/tr><tr><td>\u7f51\u7edc\u8d85\u65f6\u6216\u65e0\u6cd5\u8fde\u63a5<\/td><td>\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\uff08\u89c1\u4e0b\u65b9\uff09<\/td><\/tr><tr><td>\u5b89\u88c5 C \u6269\u5c55\u5931\u8d25\uff08\u5982 lxml\uff09<\/td><td>\u5b89\u88c5\u7f16\u8bd1\u4f9d\u8d56\uff0c\u5982 <code>build-essential<\/code>\uff0c\u6216\u4f7f\u7528 <code>wheel<\/code> \u6587\u4ef6\u5b89\u88c5<\/td><\/tr><tr><td>Windows \u62a5\u9519\u627e\u4e0d\u5230 vcvarsall<\/td><td>\u5b89\u88c5 Microsoft C++ Build Tools<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\uff08\u63d0\u5347\u4e0b\u8f7d\u901f\u5ea6\uff09<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install flask -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/code><\/pre>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u5199\u5165\u914d\u7f6e\u6587\u4ef6\uff08\u63a8\u8350\uff09\uff1a<\/p>\n\n\n\n<p><strong>Linux\/macOS: <code>~\/.pip\/pip.conf<\/code><\/strong><br><strong>Windows: <code>%APPDATA%\\pip\\pip.ini<\/code><\/strong><\/p>\n\n\n\n<p>\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;global]\nindex-url = https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\uff08\u63a8\u8350\u65b9\u5f0f\uff09<\/h2>\n\n\n\n<p>\u4f7f\u7528 <code>venv<\/code> \u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\uff0c\u907f\u514d\u5168\u5c40\u51b2\u7a81\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python -m venv venv\nsource venv\/bin\/activate     # Linux\/macOS\nvenv\\Scripts\\activate        # Windows<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u4f7f\u7528 <code>pip install<\/code> \u5b89\u88c5\u5e93\uff0c\u53ea\u4f5c\u7528\u4e8e\u5f53\u524d\u9879\u76ee\u73af\u5883\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u53c2\u8003\u94fe\u63a5\uff08\u51fa\u7ad9\uff09<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pip.pypa.io\/en\/stable\/user_guide\/\">\u5b98\u65b9 pip \u7528\u6237\u6307\u5357<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pypi.tuna.tsinghua.edu.cn\/\">\u6e05\u534e PyPI \u955c\u50cf\u7ad9<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pypi.org\/\">PyPI &#8211; Python Package Index<\/a><\/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\">\u603b\u7ed3<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u5de5\u5177<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>pip<\/code><\/td><td>\u5b98\u65b9\u63a8\u8350\u7684\u5305\u7ba1\u7406\u5de5\u5177<\/td><\/tr><tr><td><code>venv<\/code><\/td><td>\u521b\u5efa\u72ec\u7acb\u9879\u76ee\u73af\u5883<\/td><\/tr><tr><td><code>requirements.txt<\/code><\/td><td>\u6279\u91cf\u5b89\u88c5\u4f9d\u8d56\uff0c\u9879\u76ee\u7ba1\u7406\u63a8\u8350<\/td><\/tr><tr><td>\u955c\u50cf\u6e90<\/td><td>\u63d0\u5347\u901f\u5ea6\uff0c\u9002\u914d\u56fd\u5185\u7f51\u7edc\u73af\u5883<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u8bf7\u5173\u6ce8\u5176\u4ed6\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Python \u4e2d\uff0c\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 pip \u2014\u2014 Python \u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002\u4e0b\u9762\u662f\u6bd4\u8f83\u4e13\u4e1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3757,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[],"class_list":["post-3756","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=3756"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3756\/revisions"}],"predecessor-version":[{"id":3758,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3756\/revisions\/3758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/3757"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=3756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=3756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=3756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}