{"id":92110,"date":"2026-08-09T11:16:47","date_gmt":"2026-08-09T03:16:47","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92110.html"},"modified":"2026-08-09T11:16:47","modified_gmt":"2026-08-09T03:16:47","slug":"%e4%bd%a0%e7%9a%84-requirements-txt-%e4%b8%ba%e4%bd%95%e6%80%bb%e5%9c%a8%e8%83%8c%e5%8f%9b%e4%bd%a0%ef%bc%9f-%e7%89%88%e6%9c%ac%e9%94%81%e5%ae%9a%e7%ac%a6%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92110.html","title":{"rendered":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565"},"content":{"rendered":"<h2>\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60&#xff1f;\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565<\/h2>\n<p>\u5728 Python \u9879\u76ee\u91cc&#xff0c;requirements.txt \u662f\u7ba1\u7406\u4f9d\u8d56\u7684\u201c\u751f\u6b7b\u7c3f\u201d\u3002\u4e00\u884c\u884c\u5305\u540d\u4e0e\u7248\u672c\u53f7&#xff0c;\u770b\u4f3c\u7b80\u5355\u660e\u4e86&#xff0c;\u5374\u6697\u85cf\u6740\u673a\u3002\u5f88\u591a\u5f00\u53d1\u8005\u968f\u624b\u5199\u4e0b flask&gt;&#061;2.0&#xff0c;\u7b2c\u4e8c\u5929\u751f\u4ea7\u73af\u5883\u5c31\u56e0 Flask 3.0 \u7684 breaking change \u70b8\u6210\u4e00\u9505\u7ca5&#xff1b;\u4e5f\u6709\u4eba\u8654\u8bda\u5730\u6267\u884c pip freeze &gt; requirements.txt&#xff0c;\u9501\u6b7b\u4e86\u6240\u6709\u7cbe\u786e\u7248\u672c&#xff0c;\u7ed3\u679c\u6362\u53f0\u673a\u5668\u5c31\u56e0\u5e73\u53f0\u5dee\u5f02\u8fde\u5b89\u88c5\u90fd\u5931\u8d25\u3002\u66f4\u53ef\u6015\u7684\u662f&#xff0c;\u6709\u4eba\u6df7\u6dc6\u4e86 ~&#061; \u548c &gt;&#061;&#xff0c;\u4ee5\u4e3a\u9501\u5b9a\u4e86\u201c\u517c\u5bb9\u7248\u672c\u201d&#xff0c;\u5b9e\u5219\u57cb\u4e0b\u4e86\u4f9d\u8d56\u5347\u7ea7\u7684\u70b8\u5f39\u3002<\/p>\n<p>\u8fd9\u4e9b\u707e\u96be\u7684\u6e90\u5934&#xff0c;\u5168\u5728\u4e8e\u5bf9\u90a3\u51e0\u4e2a\u5c0f\u5c0f\u7684\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u2014\u2014&#061;&#061;\u3001&gt;&#061;\u3001~&#061;\u2014\u2014\u7406\u89e3\u4e0d\u6e05\u3002\u4eca\u5929&#xff0c;\u6211\u4eec\u5c31\u6765\u5f7b\u5e95\u62c6\u89e3\u6bcf\u4e00\u4e2a\u7b26\u53f7\u7684\u771f\u5b9e\u8bed\u4e49&#xff0c;\u770b\u900f\u5b83\u4eec\u7684\u201c\u6e29\u67d4\u201d\u4e0e\u201c\u66b4\u623e\u201d&#xff0c;\u5e76\u4e3a\u4f60\u953b\u9020\u4e00\u5957\u65e2\u80fd\u907f\u514d\u4f9d\u8d56\u5730\u72f1&#xff0c;\u53c8\u80fd\u4fdd\u6301\u73af\u5883\u7a33\u5b9a\u7684\u9ec4\u91d1\u6cd5\u5219\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u95ee\u9898\u590d\u73b0&#xff1a;\u4f60\u7684\u4f9d\u8d56\u4e3a\u4ec0\u4e48\u5931\u63a7&#xff1f;<\/h3>\n<h4>\u573a\u666f 1&#xff1a;&gt;&#061; \u7684\u6e29\u67d4\u4e00\u5200<\/h4>\n<p># requirements.txt<br \/>\nrequests&gt;&#061;2.25.0<\/p>\n<p>\u4f60\u4ee5\u4e3a\u8fd9\u662f\u201c\u7528 2.25.0 \u4ee5\u4e0a\u7684\u6700\u65b0\u7248\u201d&#xff0c;\u5b89\u88c5\u65f6\u4e00\u5207\u6b63\u5e38\u3002\u4e00\u4e2a\u6708\u540e&#xff0c;requests \u53d1\u5e03\u4e86 3.0&#xff0c;API \u5b8c\u5168\u4e0d\u517c\u5bb9\u3002\u4f60\u7684 CI \u6d41\u6c34\u7ebf\u7a81\u7136\u5931\u8d25&#xff0c;\u751f\u4ea7\u73af\u5883\u5728\u4e0b\u6b21\u90e8\u7f72\u65f6\u5d29\u6e83\u3002\u4f60\u56de\u770b requirements.txt&#xff0c;\u624d\u53d1\u73b0\u90a3\u4e2a &gt;&#061; \u6ca1\u6709\u4e0a\u9650&#xff0c;\u50cf\u4e00\u5339\u6ca1\u6709\u7f30\u7ef3\u7684\u91ce\u9a6c&#xff0c;\u628a\u6700\u65b0\u7684\u7834\u574f\u6027\u7248\u672c\u62c9\u8fdb\u4e86\u4f60\u7684\u9879\u76ee\u3002<\/p>\n<h4>\u573a\u666f 2&#xff1a;&#061;&#061; \u7684\u51b0\u5c01\u9b54\u5492<\/h4>\n<p># \u7531 pip freeze \u751f\u6210<br \/>\npandas&#061;&#061;1.5.3<br \/>\nnumpy&#061;&#061;1.23.5<br \/>\npython-dateutil&#061;&#061;2.8.2<br \/>\n&#8230;<\/p>\n<p>\u4f60\u5728 macOS \u4e0a\u5f00\u53d1&#xff0c;\u4e00\u5207\u5b8c\u7f8e\u3002\u540c\u4e8b\u5728 Linux \u4e0a\u514b\u9686\u9879\u76ee&#xff0c;\u6267\u884c pip install -r requirements.txt&#xff0c;\u5374\u62a5\u51fa\u51b2\u7a81&#xff1a;\u67d0\u4e9b\u5305\u7684\u7279\u5b9a\u7248\u672c\u5728 Linux \u4e0a\u6ca1\u6709\u5bf9\u5e94\u7684 wheel&#xff0c;\u6216\u8005\u4f9d\u8d56\u7684\u5e95\u5c42 C \u5e93\u7248\u672c\u4e0d\u5339\u914d\u3002\u4f60\u88ab\u9501\u6b7b\u5728\u7cbe\u786e\u7248\u672c\u4e0a&#xff0c;\u5b8c\u5168\u4e27\u5931\u4e86\u8de8\u5e73\u53f0\u5f39\u6027\u3002<\/p>\n<h4>\u573a\u666f 3&#xff1a;~&#061; \u7684\u8ff7\u4e4b\u81ea\u4fe1<\/h4>\n<p>flask~&#061;2.3.0<\/p>\n<p>\u4f60\u4ee5\u4e3a\u8fd9\u8868\u793a\u201c\u4e0e 2.3.0 \u517c\u5bb9\u7684\u7248\u672c\u201d&#xff0c;\u4e5f\u5c31\u662f 2.3.x\u3002Flask \u540e\u6765\u53d1\u5e03\u4e86 2.4.0&#xff0c;\u4f60\u81ea\u4fe1\u5730\u8ba4\u4e3a ~&#061;2.3.0 \u4e0d\u4f1a\u5b89\u88c5\u5b83\u3002\u7136\u800c\u67d0\u6b21\u90e8\u7f72\u65f6&#xff0c;Flask 2.4.0 \u8fd8\u662f\u6084\u6084\u6e9c\u4e86\u8fdb\u6765\u2014\u2014\u56e0\u4e3a\u4f60\u8bef\u89e3\u4e86 ~&#061; \u7684\u771f\u5b9e\u884c\u4e3a\u3002\u539f\u6765 ~&#061;2.3.0 \u5b9e\u9645\u4e0a\u5141\u8bb8 &gt;&#061;2.3.0, &#061;&#061;2.3.*&#xff0c;\u4e5f\u5c31\u662f 2.3.0 \u5230 2.4.0 \u4e4b\u524d\u7684\u6240\u6709\u7248\u672c\u3002\u800c 2.4.0 \u5e76\u6ca1\u6709\u88ab\u7981\u6b62&#xff0c;\u56e0\u4e3a\u5b83\u5339\u914d 2.4.*&#xff1f;\u4e0d\u5bf9&#xff01;~&#061;2.3.0 \u9501\u5b9a\u7684\u662f 2.3.*&#xff0c;\u4f46\u5982\u679c\u4f60\u5199\u7684\u662f ~&#061;2.3&#xff08;\u4e0d\u5e26\u8865\u4e01\u53f7&#xff09;&#xff0c;\u5b83\u5141\u8bb8 2.3.0 \u4ee5\u4e0a\u4f46 2.4 \u4ee5\u4e0b\u7684\u6240\u6709\u7248\u672c&#xff0c;\u5373 &gt;&#061;2.3, &#061;&#061;2.*\u3002\u8fd9\u66f4\u5bbd\u677e\u3002\u8bb8\u591a\u5f00\u53d1\u8005\u6b63\u662f\u56e0\u4e3a\u6ca1\u6709\u638c\u63e1\u8fd9\u4e2a\u7ec6\u5fae\u5dee\u522b\u800c\u7ffb\u8f66\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u5e95\u5c42\u539f\u7406&#xff1a;PEP 440 \u7248\u672c\u89c4\u8303\u4e0e\u9501\u5b9a\u7b26\u53f7\u7684\u7cbe\u786e\u8bed\u4e49<\/h3>\n<p>Python \u4f9d\u8d56\u7248\u672c\u89c4\u8303\u9075\u5faa PEP 440\u3002requirements.txt \u4e2d\u7684\u6bcf\u884c\u901a\u5e38\u683c\u5f0f\u4e3a&#xff1a;<\/p>\n<p>package_name specifier1 specifier2 &#8230;<\/p>\n<p>\u5176\u4e2d specifier \u7531\u64cd\u4f5c\u7b26\u548c\u7248\u672c\u53f7\u7ec4\u6210\u3002\u5e38\u7528\u7684\u64cd\u4f5c\u7b26\u6709&#xff1a;<\/p>\n<table>\n<tr>\u64cd\u4f5c\u7b26\u542b\u4e49\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>&#061;&#061;<\/td>\n<td>\u7cbe\u786e\u7b49\u4e8e\u8be5\u7248\u672c<\/td>\n<td>&#061;&#061;1.2.3<\/td>\n<\/tr>\n<tr>\n<td>!&#061;<\/td>\n<td>\u6392\u9664\u8be5\u7248\u672c<\/td>\n<td>!&#061;1.2.3<\/td>\n<\/tr>\n<tr>\n<td>&lt;, &lt;&#061;<\/td>\n<td>\u5c0f\u4e8e&#xff0c;\u5c0f\u4e8e\u7b49\u4e8e<\/td>\n<td>&lt;&#061;1.2<\/td>\n<\/tr>\n<tr>\n<td>&gt;, &gt;&#061;<\/td>\n<td>\u5927\u4e8e&#xff0c;\u5927\u4e8e\u7b49\u4e8e<\/td>\n<td>&gt;&#061;2.0<\/td>\n<\/tr>\n<tr>\n<td>~&#061;<\/td>\n<td>\u517c\u5bb9\u7248\u672c&#xff0c;\u76f8\u5f53\u4e8e &gt;&#061;version, &#061;&#061;version.*<\/td>\n<td>~&#061;2.3.0<\/td>\n<\/tr>\n<tr>\n<td>&#061;&#061;&#061;<\/td>\n<td>\u4efb\u610f\u76f8\u7b49&#xff08;\u6781\u5c11\u7528&#xff09;<\/td>\n<td>&#061;&#061;&#061;1.2.3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u591a\u4e2a specifier \u53ef\u4ee5\u7528\u9017\u53f7\u5206\u9694&#xff0c;\u8868\u793a\u201c\u4e14\u201d\u7684\u5173\u7cfb\u3002\u4f8b\u5982&#xff1a;&gt;&#061;1.0, &lt;2.0 \u8868\u793a 1.0 \u5230 2.0 \u4e4b\u95f4\u7684\u7248\u672c\u3002<\/p>\n<h4>1. &#061;&#061;&#xff1a;\u7cbe\u786e\u9501\u5b9a<\/h4>\n<p>\u6700\u4e25\u683c\u7684\u7ea6\u675f\u3002\u53ea\u5141\u8bb8\u5b89\u88c5\u6307\u5b9a\u7684\u786e\u5207\u7248\u672c\u3002\u8fd9\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u63d0\u4f9b\u7edd\u5bf9\u7684\u786e\u5b9a\u6027&#xff0c;\u4f46\u4e5f\u727a\u7272\u4e86\u7075\u6d3b\u6027\u3002\u5982\u679c\u8be5\u7248\u672c\u5b58\u5728 bug \u6216\u5b89\u5168\u6f0f\u6d1e&#xff0c;\u4f60\u5fc5\u987b\u624b\u52a8\u5347\u7ea7\u6587\u4ef6\u3002\u540c\u65f6&#xff0c;\u8de8\u5e73\u53f0\u65f6\u53ef\u80fd\u56e0\u4e3a\u4e8c\u8fdb\u5236\u517c\u5bb9\u6027\u800c\u5b89\u88c5\u5931\u8d25\u3002<\/p>\n<h4>2. &gt;&#061;&#xff1a;\u6700\u5c0f\u7248\u672c&#xff0c;\u65e0\u4e0a\u9650<\/h4>\n<p>\u53ea\u9650\u5236\u6700\u4f4e\u7248\u672c&#xff0c;\u5bf9\u4e0a\u9650\u5b8c\u5168\u655e\u5f00\u3002\u8fd9\u5728\u5e93\u7684 install_requires \u4e2d\u5f88\u5e38\u89c1&#xff0c;\u56e0\u4e3a\u5e93\u5e94\u5c3d\u91cf\u517c\u5bb9\u5e7f\u6cdb\u7684\u7248\u672c\u3002\u4f46\u5728\u5e94\u7528\u7a0b\u5e8f\u7684 requirements.txt \u4e2d&#xff0c;\u8fd9\u662f\u6781\u5ea6\u5371\u9669\u7684&#xff0c;\u56e0\u4e3a\u4e3b\u7248\u672c\u5347\u7ea7\u53ef\u80fd\u5f15\u5165\u4e0d\u517c\u5bb9\u7684 API \u53d8\u5316&#xff0c;\u7834\u574f\u5e94\u7528\u3002<\/p>\n<h4>3. ~&#061;&#xff1a;\u517c\u5bb9\u7248\u672c&#xff08;\u6ce2\u6d6a\u53f7\u7b49\u4e8e&#xff09;<\/h4>\n<p>~&#061; \u662f PEP 440 \u5b9a\u4e49\u7684\u201c\u517c\u5bb9\u7248\u672c\u201d\u64cd\u4f5c\u7b26\u3002\u5b83\u7684\u884c\u4e3a\u53ef\u4ee5\u7406\u89e3\u4e3a&#xff1a;<\/p>\n<p>package ~&#061; X.Y.Z \u7b49\u4ef7\u4e8e package &gt;&#061; X.Y.Z, &#061;&#061; X.Y.*<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u9501\u5b9a\u4e3b\u7248\u672c X \u548c\u6b21\u7248\u672c Y \u4e0d\u53d8&#xff0c;\u5141\u8bb8\u4fee\u8ba2\u53f7 Z \u53ca\u5176\u4ee5\u4e0a\u7684\u4efb\u4f55\u4fee\u8ba2\u3002\u4f8b\u5982&#xff1a;<\/p>\n<ul>\n<li>~&#061;2.3.0 \u2192 &gt;&#061;2.3.0, &#061;&#061;2.3.*&#xff08;\u5373 2.3.0\u30012.3.1\u30012.3.2\u2026\u4f46\u4e0d\u4f1a\u5230 2.4.0&#xff09;<\/li>\n<li>~&#061;2.3 \u2192 &gt;&#061;2.3, &#061;&#061;2.*&#xff08;\u5373 2.3, 2.4, 2.5\u2026\u4f46\u4e0d\u4f1a\u5230 3.0&#xff09;<\/li>\n<li>~&#061;2 \u2192 &gt;&#061;2, &#061;&#061;2.*&#xff08;\u4e0e\u4e0a\u4e00\u6761\u76f8\u540c&#xff0c;\u56e0\u4e3a\u53ea\u6307\u5b9a\u4e86\u4e3b\u7248\u672c&#xff09;<\/li>\n<\/ul>\n<p>\u8fd9\u4e2a\u64cd\u4f5c\u7b26\u7684\u8bbe\u8ba1\u521d\u8877\u662f&#xff1a;\u5728\u4fdd\u8bc1\u4e0d\u5f15\u5165\u4e0d\u517c\u5bb9 API \u53d8\u5316\u7684\u524d\u63d0\u4e0b&#xff0c;\u5141\u8bb8\u4fee\u8ba2\u7ea7\u522b\u7684 bug \u4fee\u590d\u548c\u5b89\u5168\u66f4\u65b0\u3002\u56e0\u4e3a\u6309\u7167\u8bed\u4e49\u5316\u7248\u672c&#xff0c;\u4fee\u8ba2\u53f7\u7684\u53d8\u5316\u4e0d\u5e94\u5305\u542b API \u53d8\u52a8&#xff0c;\u6b21\u7248\u672c\u53f7\u7684\u53d8\u5316\u5305\u542b\u5411\u540e\u517c\u5bb9\u7684\u529f\u80fd&#xff0c;\u4e3b\u7248\u672c\u53f7\u53d8\u5316\u5305\u542b\u4e0d\u517c\u5bb9\u7684\u6539\u52a8\u3002<\/p>\n<p>\u5e38\u89c1\u8bef\u89e3&#xff1a;\u5f88\u591a\u4eba\u4ee5\u4e3a ~&#061;2.3.0 \u4f1a\u9501\u5b9a\u5230 2.3.x \u5e76\u4e0d\u5141\u8bb8 2.4.0&#xff0c;\u8fd9\u662f\u6b63\u786e\u7684\u3002\u4f46\u8bef\u4ee5\u4e3a ~&#061;2.3&#xff08;\u6ca1\u5199\u8865\u4e01\u53f7&#xff09;\u4e5f\u4f1a\u53ea\u9501\u5b9a 2.3.x&#xff0c;\u90a3\u5c31\u9519\u4e86\u2014\u2014\u5b83\u4f1a\u4e00\u8def\u5141\u8bb8 2.x \u7684\u6240\u6709\u7248\u672c&#xff0c;\u76f4\u5230 3.0\u3002\u56e0\u6b64&#xff0c;\u5982\u679c\u53ea\u60f3\u9501\u5b9a 2.3.x&#xff0c;\u5fc5\u987b\u660e\u786e\u5199\u51fa\u8865\u4e01\u53f7&#xff1a;~&#061;2.3.0\u3002<\/p>\n<h4>4. \u590d\u5408\u7248\u672c\u7ea6\u675f<\/h4>\n<p>\u4f60\u53ef\u4ee5\u7ec4\u5408\u591a\u4e2a specifier \u6765\u5b9e\u73b0\u7cbe\u786e\u7684\u8303\u56f4\u63a7\u5236\u3002\u4f8b\u5982&#xff1a;<\/p>\n<ul>\n<li>requests&gt;&#061;2.25.0, &lt;3.0  \u660e\u786e\u9501\u5b9a\u5728 2.x \u7cfb\u5217\u3002<\/li>\n<li>Django&gt;&#061;3.2, &lt;4.0  \u5141\u8bb8 3.2 \u5230 3.x \u7684\u6700\u65b0\u7248\u672c&#xff0c;\u62d2\u7edd 4.0\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u662f\u6bd4 ~&#061; \u66f4\u7075\u6d3b\u4e14\u610f\u56fe\u660e\u786e\u7684\u65b9\u5f0f\u3002<\/p>\n<h4>5. \u4e3a\u4ec0\u4e48 pip freeze \u4f1a\u751f\u6210\u7cbe\u786e\u7248\u672c&#xff1f;<\/h4>\n<p>pip freeze \u8f93\u51fa\u5f53\u524d\u73af\u5883\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u5305\u53ca\u5176\u7cbe\u786e\u7248\u672c&#xff0c;\u8fd9\u5bf9\u4e8e\u91cd\u73b0\u73af\u5883\u5f88\u6709\u7528\u3002\u4f46\u5982\u679c\u76f4\u63a5\u5c06\u5176\u4f5c\u4e3a requirements.txt \u7528\u4e8e\u5176\u4ed6\u5e73\u53f0\u6216\u65b0\u73af\u5883&#xff0c;\u5c31\u53ef\u80fd\u56e0\u5e73\u53f0\u7684 wheel \u53ef\u7528\u6027\u6216\u4f9d\u8d56\u51b2\u7a81\u800c\u5931\u8d25\u3002\u5b83\u672c\u8d28\u4e0a\u662f\u201c\u9501\u5b9a\u6587\u4ef6\u201d&#xff08;lock file&#xff09;&#xff0c;\u800c\u4e0d\u662f\u901a\u7528\u7684\u201c\u9700\u6c42\u6587\u4ef6\u201d\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u5e38\u89c1\u9677\u9631\u4e0e\u707e\u96be\u6a21\u5f0f<\/h3>\n<h4>\u9677\u9631 1&#xff1a;\u5e94\u7528\u4e0e\u5e93\u6df7\u6dc6&#xff0c;\u5e94\u7528\u6587\u4ef6\u6ee5\u7528 &gt;&#061;<\/h4>\n<p>\u8bb8\u591a\u5f00\u53d1\u8005\u76f4\u63a5\u5c06 install_requires \u4e2d\u7684\u5bbd\u6cdb\u7ea6\u675f\u590d\u5236\u5230 requirements.txt&#xff0c;\u5bfc\u81f4\u5e94\u7528\u66b4\u9732\u5728\u4e0d\u53d7\u63a7\u7684\u5347\u7ea7\u4e2d\u3002\u5e94\u7528\u5e94\u8be5\u4f7f\u7528\u7cbe\u786e\u6216\u8303\u56f4\u9501\u5b9a\u7684\u7248\u672c&#xff0c;\u800c\u5e93\u5e94\u8be5\u5c3d\u91cf\u5bbd\u677e\u4ee5\u517c\u5bb9\u66f4\u591a\u73af\u5883\u3002<\/p>\n<h4>\u9677\u9631 2&#xff1a;~&#061; \u6ca1\u5199\u5b8c\u6574\u7248\u672c\u53f7<\/h4>\n<p>\u5982\u679c\u53ea\u5199\u4e86 package~&#061;2.3&#xff0c;\u800c\u6ca1\u6709\u8865\u4e01\u53f7&#xff0c;\u610f\u5473\u7740 &gt;&#061;2.3, &#061;&#061;2.*\u3002\u4e3b\u7248\u672c 2 \u4e0b\u7684\u6240\u6709\u6b21\u7248\u672c\u5347\u7ea7\u90fd\u4f1a\u88ab\u63a5\u53d7&#xff0c;\u8fd9\u53ef\u80fd\u5e76\u4e0d\u662f\u4f60\u7684\u672c\u610f\u3002\u8981\u9501\u5b9a\u5230\u7279\u5b9a\u6b21\u7248\u672c&#xff0c;\u5fc5\u987b\u5305\u542b\u8865\u4e01\u53f7&#xff1a;package~&#061;2.3.0\u3002<\/p>\n<h4>\u9677\u9631 3&#xff1a;\u5fd8\u8bb0\u4f20\u9012\u4f9d\u8d56\u7684\u7248\u672c\u51b2\u7a81<\/h4>\n<p>\u5373\u4f7f\u4f60\u9501\u5b9a\u4e86\u76f4\u63a5\u4f9d\u8d56&#xff0c;\u5b83\u4eec\u7684\u5b50\u4f9d\u8d56\u53ef\u80fd\u4f9d\u7136\u4f1a\u56e0 &gt;&#061; \u800c\u5347\u7ea7&#xff0c;\u9020\u6210\u51b2\u7a81\u3002pip \u7684\u4f9d\u8d56\u89e3\u6790\u5668\u4f1a\u5c3d\u91cf\u627e\u5230\u517c\u5bb9\u96c6\u5408&#xff0c;\u4f46\u53ef\u80fd\u51fa\u73b0\u201c\u4f9d\u8d56\u5730\u72f1\u201d\u3002\u4f7f\u7528 pip-tools \u7684 pip-compile \u53ef\u4ee5\u751f\u6210\u5b8c\u6574\u7684\u9501\u5b9a\u6587\u4ef6&#xff08;\u5305\u542b\u6240\u6709\u4f20\u9012\u4f9d\u8d56\u7684\u7cbe\u786e\u7248\u672c&#xff09;&#xff0c;\u8fd9\u662f\u66f4\u53ef\u9760\u7684\u505a\u6cd5\u3002<\/p>\n<h4>\u9677\u9631 4&#xff1a;\u6df7\u5408\u4f7f\u7528 &gt;&#061; \u548c &#061;&#061; \u5bfc\u81f4\u51b2\u7a81<\/h4>\n<p>packageA&#061;&#061;1.0<br \/>\npackageB&gt;&#061;1.5<\/p>\n<p>\u5982\u679c packageB \u7684\u65b0\u7248\u672c\u9700\u8981 packageA&gt;&#061;2.0&#xff0c;\u5219\u5b89\u88c5\u65f6\u4f1a\u5931\u8d25\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u6ca1\u6709\u6574\u4f53\u534f\u8c03\u4f9d\u8d56\u3002<\/p>\n<h4>\u9677\u9631 5&#xff1a;\u624b\u52a8\u7f16\u8f91 requirements.txt \u540e\u672a\u540c\u6b65 pip freeze<\/h4>\n<p>\u6709\u4e9b\u4eba\u65e2\u60f3\u9501\u5b9a\u7248\u672c&#xff0c;\u53c8\u624b\u52a8\u6dfb\u52a0\u65b0\u5305&#xff0c;\u7ed3\u679c\u5fd8\u8bb0\u91cd\u65b0 pip freeze&#xff0c;\u5bfc\u81f4\u6587\u4ef6\u4e2d\u7684\u7248\u672c\u4e0e\u5b9e\u9645\u73af\u5883\u4e0d\u4e00\u81f4&#xff0c;\u7ed9\u534f\u4f5c\u57cb\u4e0b\u5730\u96f7\u3002<\/p>\n<h4>\u9677\u9631 6&#xff1a;\u5ffd\u7565\u73af\u5883\u6807\u8bb0&#xff08;environment markers&#xff09;<\/h4>\n<p>\u6709\u65f6\u4f60\u53ef\u80fd\u9700\u8981\u4e3a\u4e0d\u540c\u5e73\u53f0\u6307\u5b9a\u4e0d\u540c\u7684\u4f9d\u8d56&#xff0c;\u4f46\u76f4\u63a5\u5199\u6b7b\u5728 requirements.txt \u800c\u6ca1\u6709\u7528\u73af\u5883\u6807\u8bb0&#xff0c;\u4f1a\u5bfc\u81f4\u8de8\u5e73\u53f0\u5b89\u88c5\u5931\u8d25\u3002\u53ef\u4ee5\u4f7f\u7528 ; sys_platform &#061;&#061; &#039;win32&#039; \u7b49\u6807\u8bb0&#xff0c;\u4f46\u901a\u5e38\u66f4\u597d\u7684\u505a\u6cd5\u662f\u4f7f\u7528 setup.cfg \u6216 pyproject.toml \u4e2d\u7684 extras\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u5b89\u5168\u4f7f\u7528\u7248\u672c\u7ea6\u675f\u7684\u9ec4\u91d1\u6cd5\u5219<\/h3>\n<h4>\u6cd5\u5219\u4e00&#xff1a;\u4e3a\u5e94\u7528\u7a0b\u5e8f\u751f\u6210\u9501\u5b9a\u6587\u4ef6&#xff0c;\u4e3a\u5e93\u4fdd\u7559\u5bbd\u677e\u7ea6\u675f<\/h4>\n<ul>\n<li>\u5e94\u7528\u7a0b\u5e8f&#xff08;\u6700\u7ec8\u90e8\u7f72\u7684\u670d\u52a1\u3001\u811a\u672c&#xff09;&#xff1a;\u4f7f\u7528 pip freeze &gt; requirements.txt \u751f\u6210\u7cbe\u786e\u7248\u672c&#xff0c;\u6216\u4f7f\u7528 pip-tools \u7684 pip-compile \u751f\u6210 requirements.txt&#xff08;\u9501\u5b9a\u6240\u6709\u4f9d\u8d56&#xff09;\u3002<\/li>\n<li>\u5e93&#xff08;\u53d1\u5e03\u5230 PyPI \u7684\u5305&#xff09;&#xff1a;\u5728 setup.cfg \u6216 pyproject.toml \u4e2d\u4f7f\u7528 &gt;&#061; \u548c &lt; \u9650\u5b9a\u5df2\u77e5\u517c\u5bb9\u7684\u8303\u56f4&#xff0c;\u5982 Django&gt;&#061;3.2, &lt;4.0&#xff0c;\u907f\u514d\u4f7f\u7528\u7cbe\u786e\u9501\u5b9a\u3002<\/li>\n<\/ul>\n<h4>\u6cd5\u5219\u4e8c&#xff1a;\u4f18\u5148\u4f7f\u7528\u590d\u5408\u7248\u672c\u7ea6\u675f\u4ee3\u66ff ~&#061;<\/h4>\n<p>\u867d\u7136 ~&#061; \u63d0\u4f9b\u4e86\u7b80\u6d01\u7684\u517c\u5bb9\u9501\u5b9a&#xff0c;\u4f46\u5b83\u7684\u8bed\u4e49\u5e76\u4e0d\u76f4\u89c2&#xff0c;\u5bb9\u6613\u8bef\u7528\u3002\u66f4\u6e05\u6670\u7684\u8868\u8fbe\u65b9\u5f0f\u662f\u4f7f\u7528 &gt;&#061;X.Y, &lt;X&#043;1.0 \u6216 &gt;&#061;X.Y.Z, &lt;X.Y&#043;1.0\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p>flask&gt;&#061;2.3.0, &lt;2.4.0    # \u9501\u5b9a\u5728 2.3.x \u7cfb\u5217<br \/>\nrequests&gt;&#061;2.25.0, &lt;3.0   # \u9501\u5b9a\u5728 2.x \u7cfb\u5217<\/p>\n<p>\u8fd9\u79cd\u5199\u6cd5\u8c01\u90fd\u80fd\u4e00\u773c\u770b\u61c2&#xff0c;\u4e14\u7cbe\u786e\u63a7\u5236\u5347\u7ea7\u8fb9\u754c\u3002<\/p>\n<h4>\u6cd5\u5219\u4e09&#xff1a;\u4f7f\u7528 pip-tools \u5206\u79bb\u201c\u9700\u6c42\u201d\u4e0e\u201c\u9501\u5b9a\u201d<\/h4>\n<p>\u6700\u4f73\u5b9e\u8df5\u662f\u7ef4\u62a4\u4e24\u4e2a\u6587\u4ef6&#xff1a;<\/p>\n<ul>\n<li>requirements.in&#xff1a;\u5199\u660e\u9876\u5c42\u76f4\u63a5\u4f9d\u8d56\u53ca\u5bbd\u677e\u7ea6\u675f&#xff08;\u5982 flask&gt;&#061;2.3.0, &lt;2.4.0&#xff09;<\/li>\n<li>requirements.txt&#xff1a;\u7531 pip-compile \u81ea\u52a8\u751f\u6210&#xff0c;\u5305\u542b\u6240\u6709\u4f9d\u8d56\u7684\u7cbe\u786e\u7248\u672c<\/li>\n<\/ul>\n<p>\u8fd9\u6837\u4f60\u65e2\u53ef\u4ee5\u4eab\u53d7\u53ef\u63a7\u7684\u5347\u7ea7&#xff0c;\u53c8\u6709\u53ef\u91cd\u73b0\u7684\u6784\u5efa\u3002\u8981\u5347\u7ea7\u4f9d\u8d56\u65f6&#xff0c;\u53ea\u9700\u66f4\u65b0 .in \u6587\u4ef6\u5e76\u91cd\u65b0\u7f16\u8bd1\u3002<\/p>\n<h4>\u6cd5\u5219\u56db&#xff1a;\u907f\u514d\u4f7f\u7528 &gt;&#061; \u800c\u4e0d\u52a0\u4e0a\u9650<\/h4>\n<p>\u9664\u975e\u4f60\u975e\u5e38\u786e\u4fe1\u4f9d\u8d56\u7684\u4e3b\u7248\u672c\u4f1a\u957f\u671f\u517c\u5bb9&#xff0c;\u5426\u5219\u603b\u662f\u52a0\u4e0a\u4e0a\u9650\u3002\u4f8b\u5982 &gt;&#061;2.3.0, &lt;3.0\u3002\u5bf9\u4e8e\u5c1a\u672a\u53d1\u5e03\u4e3b\u7248\u672c&#xff08;0.x&#xff09;\u7684\u5305&#xff0c;\u4e0b\u9650\u548c\u4e0a\u9650\u90fd\u5fc5\u987b\u660e\u786e&#xff0c;\u56e0\u4e3a 0.x \u7684\u6bcf\u6b21\u5c0f\u7248\u672c\u90fd\u53ef\u80fd\u7834\u574f API\u3002<\/p>\n<h4>\u6cd5\u5219\u4e94&#xff1a;\u5b9a\u671f\u5ba1\u67e5\u548c\u66f4\u65b0\u4f9d\u8d56<\/h4>\n<p>\u4f7f\u7528\u5de5\u5177\u5982 pip list &#8211;outdated \u68c0\u67e5\u8fc7\u671f\u5305&#xff0c;\u7ed3\u5408 pip-tools \u7684\u5347\u7ea7\u529f\u80fd&#xff0c;\u5b9a\u671f\u66f4\u65b0\u9501\u5b9a\u6587\u4ef6\u3002\u540c\u65f6\u501f\u52a9 CI \u8fd0\u884c\u6d4b\u8bd5&#xff0c;\u786e\u4fdd\u65b0\u7248\u672c\u4e0d\u4f1a\u7834\u574f\u5e94\u7528\u3002<\/p>\n<h4>\u6cd5\u5219\u516d&#xff1a;\u5728\u56e2\u961f\u4e2d\u660e\u786e\u7248\u672c\u7ea6\u675f\u89c4\u8303<\/h4>\n<p>\u7ea6\u5b9a&#xff1a;<\/p>\n<ul>\n<li>\u5e94\u7528 requirements.txt \u5fc5\u987b\u9501\u5b9a\u7cbe\u786e\u7248\u672c&#xff08;\u901a\u8fc7 pip-compile \u6216 pip freeze \u5ba1\u6838&#xff09;\u3002<\/li>\n<li>\u5e93\u7684 install_requires \u4f7f\u7528 &gt;&#061;X, &lt;Y \u683c\u5f0f\u3002<\/li>\n<li>\u7981\u6b62\u5728\u5e94\u7528\u4e2d\u4f7f\u7528 &gt;&#061; \u4e0d\u52a0\u4e0a\u9650\u3002<\/li>\n<li>~&#061; \u4ec5\u9650\u4e8e\u5185\u90e8\u5de5\u5177\u4e14\u9700\u8981\u6ce8\u91ca\u8bf4\u660e\u5176\u610f\u56fe\u3002<\/li>\n<li>\u6240\u6709 requirements.txt \u7684\u53d8\u66f4\u5fc5\u987b\u7ecf\u8fc7\u4ee3\u7801\u5ba1\u67e5&#xff0c;\u5c24\u5176\u662f\u5bf9\u624b\u52a8\u7f16\u8f91\u3002<\/li>\n<\/ul>\n<h4>\u6cd5\u5219\u4e03&#xff1a;\u4f7f\u7528 pip install &#8211;require-hashes \u6216 hash checking \u63d0\u5347\u5b89\u5168\u6027<\/h4>\n<p>\u5bf9\u4e8e\u751f\u4ea7\u73af\u5883&#xff0c;\u53ef\u4ee5\u5728 requirements.txt \u4e2d\u52a0\u5165\u54c8\u5e0c\u503c&#xff0c;\u786e\u4fdd\u4e0b\u8f7d\u7684\u5305\u672a\u88ab\u7be1\u6539\u3002pip-compile \u652f\u6301\u751f\u6210\u5e26\u54c8\u5e0c\u7684\u9501\u5b9a\u6587\u4ef6\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u8c03\u8bd5\u4e0e\u4f9d\u8d56\u51b2\u7a81\u89e3\u51b3\u6280\u5de7<\/h3>\n<li>\u4f7f\u7528 pip check&#xff1a;\u68c0\u67e5\u5df2\u5b89\u88c5\u5305\u662f\u5426\u5b58\u5728\u4f9d\u8d56\u51b2\u7a81\u3002<\/li>\n<li>\u4f7f\u7528 pipdeptree&#xff1a;\u53ef\u89c6\u5316\u4f9d\u8d56\u6811&#xff0c;\u627e\u51fa\u54ea\u4e2a\u5305\u5f15\u5165\u4e86\u4e0d\u53d7\u6b22\u8fce\u7684\u7248\u672c\u3002<\/li>\n<li>\u5347\u7ea7 pip \u672c\u8eab&#xff1a;\u65b0\u7248\u7684\u4f9d\u8d56\u89e3\u6790\u5668&#xff08;\u5982 2020 \u5e74\u540e\u7684 resolver&#xff09;\u80fd\u66f4\u597d\u5730\u5904\u7406\u51b2\u7a81\u5e76\u7ed9\u51fa\u660e\u786e\u63d0\u793a\u3002<\/li>\n<li>\u6d4b\u8bd5\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u7684\u5b89\u88c5&#xff1a;\u5728 CI \u77e9\u9635\u4e2d\u6d4b\u8bd5 Linux\u3001macOS\u3001Windows&#xff0c;\u786e\u4fdd\u9501\u5b9a\u7684\u7248\u672c\u90fd\u53ef\u4ee5\u5b89\u88c5\u3002<\/li>\n<li>\u56de\u9000\u5230\u5df2\u77e5\u53ef\u5de5\u4f5c\u7684\u96c6\u5408&#xff1a;\u4fdd\u7559\u4e0a\u4e00\u4e2a\u53ef\u7528\u7684 requirements.txt \u7248\u672c&#xff0c;\u4ee5\u4fbf\u5feb\u901f\u56de\u6eda\u3002<\/li>\n<li>\u4e86\u89e3\u8bed\u4e49\u5316\u7248\u672c&#xff08;SemVer&#xff09;&#xff1a;\u7406\u89e3\u5e93\u7684\u4f5c\u8005\u5982\u4f55\u4f7f\u7528\u7248\u672c\u53f7&#xff0c;\u6709\u52a9\u4e8e\u4f60\u6b63\u786e\u8bbe\u7f6e\u8303\u56f4\u3002<\/li>\n<hr \/>\n<h3>\u516d\u3001\u6700\u4f73\u5b9e\u8df5\u603b\u7ed3<\/h3>\n<ul>\n<li>\u5e94\u7528\u4f7f\u7528\u7cbe\u786e\u9501\u5b9a&#xff08;&#061;&#061;&#xff09;\u6216\u7f16\u8bd1\u540e\u7684\u9501\u5b9a\u6587\u4ef6&#xff0c;\u5e93\u4f7f\u7528\u8303\u56f4&#xff08;&gt;&#061;X, &lt;Y&#xff09;\u3002<\/li>\n<li>\u4e0d\u8981\u76f4\u63a5\u4f7f\u7528 pip freeze &gt; requirements.txt \u4f5c\u4e3a\u8de8\u5e73\u53f0\u7684\u9700\u6c42\u6587\u4ef6&#xff0c;\u9664\u975e\u4f60\u786e\u8ba4\u5176\u5185\u5bb9\u3002<\/li>\n<li>\u4f7f\u7528 pip-compile \u548c .in \u6587\u4ef6\u7ba1\u7406\u9876\u5c42\u4f9d\u8d56&#xff0c;\u751f\u6210\u9501\u5b9a\u6587\u4ef6\u3002<\/li>\n<li>\u5f53\u9501\u5b9a\u8303\u56f4\u65f6&#xff0c;\u4f18\u5148\u4f7f\u7528 &gt;&#061;X.Y, &lt;X&#043;1.0 \u800c\u4e0d\u662f ~&#061;&#xff0c;\u610f\u56fe\u66f4\u6e05\u6670\u3002<\/li>\n<li>\u6c38\u8fdc\u4e0d\u8981\u5bf9\u5e94\u7528\u7a0b\u5e8f\u4f9d\u8d56\u4f7f\u7528\u65e0\u4e0a\u9650\u7684 &gt;&#061;\u3002<\/li>\n<li>~&#061; \u53ea\u7528\u4e8e\u4f60\u5b8c\u5168\u7406\u89e3\u5176\u884c\u4e3a&#xff0c;\u5e76\u4e14\u660e\u786e\u60f3\u9501\u5b9a\u5230\u6b21\u7248\u672c\u6216\u4fee\u8ba2\u7248\u672c\u3002<\/li>\n<li>\u4e3a requirements.txt \u53d8\u66f4\u8bbe\u7f6e\u4ee3\u7801\u5ba1\u67e5&#xff0c;\u9632\u6b62\u610f\u5916\u5347\u7ea7\u3002<\/li>\n<li>\u5b9a\u671f\u66f4\u65b0\u4f9d\u8d56\u5e76\u8fd0\u884c\u5b8c\u6574\u6d4b\u8bd5&#xff0c;\u4fdd\u6301\u5b89\u5168\u6027\u548c\u517c\u5bb9\u6027\u3002<\/li>\n<li>\u5728 CI \u4e2d\u52a0\u5165 pip check \u548c\u4f9d\u8d56\u626b\u63cf&#xff0c;\u786e\u4fdd\u4f9d\u8d56\u5065\u5eb7\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e03\u3001\u7ed3\u8bed<\/h3>\n<p>requirements.txt \u91cc\u7684\u6bcf\u4e00\u4e2a\u7248\u672c\u7b26\u53f7&#xff0c;\u90fd\u662f\u4f60\u4e0e\u672a\u6765\u4f9d\u8d56\u4e4b\u95f4\u7684\u4e00\u4efd\u5951\u7ea6\u3002&#061;&#061; \u662f\u4e00\u5f20\u7ed3\u5a5a\u8bc1\u4e66&#xff0c;\u5c06\u4f60\u4e0e\u7279\u5b9a\u7248\u672c\u7262\u7262\u7ed1\u5b9a&#xff0c;\u98ce\u96e8\u540c\u821f&#xff1b;&gt;&#061; \u662f\u4e00\u5c01\u5f00\u653e\u7684\u60c5\u4e66&#xff0c;\u6b22\u8fce\u4e00\u5207\u65b0\u6765\u8005&#xff0c;\u5374\u4e5f\u53ef\u80fd\u62db\u6765\u4e0d\u901f\u4e4b\u5ba2&#xff1b;~&#061; \u5219\u662f\u6234\u7740\u9762\u7eb1\u7684\u627f\u8bfa&#xff0c;\u4f60\u4ee5\u4e3a\u5b83\u9501\u5b9a\u4e86\u6e29\u67d4\u7684\u8fb9\u754c&#xff0c;\u5b9e\u9645\u5374\u53ef\u80fd\u5728\u4f60\u719f\u7761\u65f6\u6084\u7136\u8de8\u8d8a\u3002\u7f16\u5199\u4f9d\u8d56\u6587\u4ef6&#xff0c;\u4e0d\u662f\u5728\u73a9\u731c\u8c1c\u6e38\u620f&#xff0c;\u800c\u662f\u5728\u4e3a\u4f60\u7684\u4ee3\u7801\u5efa\u7acb\u4e00\u4e2a\u53ef\u9760\u7684\u8fd0\u884c\u5730\u57fa\u3002\u7406\u6e05\u6bcf\u4e00\u4e2a\u7b26\u53f7\u7684\u7cbe\u786e\u8bed\u4e49&#xff0c;\u7528\u5de5\u5177\u5c06\u610f\u56fe\u56fa\u5316&#xff0c;\u4f60\u7684\u9879\u76ee\u5c31\u518d\u4e5f\u4e0d\u4f1a\u88ab\u201c\u7a81\u5982\u5176\u6765\u7684\u7248\u672c\u5347\u7ea7\u201d\u6253\u4e2a\u63aa\u624b\u4e0d\u53ca\u3002\u4ece\u4eca\u5929\u8d77&#xff0c;\u5ba1\u89c6\u4f60\u7684\u6bcf\u4e00\u4e2a requirements.txt&#xff0c;\u7528\u6b63\u786e\u7684\u7b26\u53f7\u4e66\u5199\u4f9d\u8d56\u7684\u8fb9\u754c&#xff0c;\u8ba9\u7a33\u5b9a\u6210\u4e3a\u5e38\u6001&#xff0c;\u8ba9\u5931\u63a7\u6210\u4e3a\u5386\u53f2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60&#xff1f;\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565<br \/>\n\u5728 Python \u9879\u76ee\u91cc&#xff0c;requirements.txt \u662f\u7ba1\u7406\u4f9d\u8d56\u7684\u201c\u751f\u6b7b\u7c3f\u201d\u3002\u4e00\u884c\u884c\u5305\u540d\u4e0e\u7248\u672c\u53f7&#xff0c;\u770b\u4f3c\u7b80\u5355\u660e\u4e86&#xff0c;\u5374\u6697\u85cf\u6740\u673a\u3002\u5f88\u591a\u5f00\u53d1\u8005\u968f\u624b\u5199\u4e0b flask&gt;2.0&#xff0c;\u7b2c\u4e8c\u5929\u751f\u4ea7\u73af\u5883\u5c31\u56e0 Flask 3.0 \u7684 breaking change \u70b8\u6210\u4e00\u9505\u7ca5&#xff1b;\u4e5f\u6709\u4eba\u8654\u8bda\u5730\u6267\u884c pip freeze <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81],"topic":[],"class_list":["post-92110","post","type-post","status-publish","format-standard","hentry","category-server","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/92110.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60&#xff1f;\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 \u5728 Python \u9879\u76ee\u91cc&#xff0c;requirements.txt \u662f\u7ba1\u7406\u4f9d\u8d56\u7684\u201c\u751f\u6b7b\u7c3f\u201d\u3002\u4e00\u884c\u884c\u5305\u540d\u4e0e\u7248\u672c\u53f7&#xff0c;\u770b\u4f3c\u7b80\u5355\u660e\u4e86&#xff0c;\u5374\u6697\u85cf\u6740\u673a\u3002\u5f88\u591a\u5f00\u53d1\u8005\u968f\u624b\u5199\u4e0b flask&gt;2.0&#xff0c;\u7b2c\u4e8c\u5929\u751f\u4ea7\u73af\u5883\u5c31\u56e0 Flask 3.0 \u7684 breaking change \u70b8\u6210\u4e00\u9505\u7ca5&#xff1b;\u4e5f\u6709\u4eba\u8654\u8bda\u5730\u6267\u884c pip freeze\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92110.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-09T03:16:47+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92110.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92110.html\",\"name\":\"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-09T03:16:47+00:00\",\"dateModified\":\"2026-08-09T03:16:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92110.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92110.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92110.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/92110.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60&#xff1f;\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 \u5728 Python \u9879\u76ee\u91cc&#xff0c;requirements.txt \u662f\u7ba1\u7406\u4f9d\u8d56\u7684\u201c\u751f\u6b7b\u7c3f\u201d\u3002\u4e00\u884c\u884c\u5305\u540d\u4e0e\u7248\u672c\u53f7&#xff0c;\u770b\u4f3c\u7b80\u5355\u660e\u4e86&#xff0c;\u5374\u6697\u85cf\u6740\u673a\u3002\u5f88\u591a\u5f00\u53d1\u8005\u968f\u624b\u5199\u4e0b flask&gt;2.0&#xff0c;\u7b2c\u4e8c\u5929\u751f\u4ea7\u73af\u5883\u5c31\u56e0 Flask 3.0 \u7684 breaking change \u70b8\u6210\u4e00\u9505\u7ca5&#xff1b;\u4e5f\u6709\u4eba\u8654\u8bda\u5730\u6267\u884c pip freeze","og_url":"https:\/\/www.wsisp.com\/helps\/92110.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-09T03:16:47+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92110.html","url":"https:\/\/www.wsisp.com\/helps\/92110.html","name":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-09T03:16:47+00:00","dateModified":"2026-08-09T03:16:47+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92110.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92110.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92110.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f60\u7684 requirements.txt \u4e3a\u4f55\u603b\u5728\u201c\u80cc\u53db\u201d\u4f60\uff1f\u2014\u2014\u7248\u672c\u9501\u5b9a\u7b26\u53f7\u7684\u81f4\u547d\u8bef\u89e3\u4e0e\u5b89\u5168\u7b56\u7565"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=92110"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92110\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92110"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}