{"id":204,"date":"2024-04-30T07:27:04","date_gmt":"2024-04-29T23:27:04","guid":{"rendered":"https:\/\/www.daogu.work\/?p=204"},"modified":"2024-04-30T07:27:04","modified_gmt":"2024-04-29T23:27:04","slug":"python%e4%b8%ad%e7%9a%84pip%e5%b8%b8%e8%a7%81%e7%94%a8%e6%b3%95%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/daogu.work\/?p=204","title":{"rendered":"python\u4e2d\u7684pip\u5e38\u89c1\u7528\u6cd5\u8bf4\u660e"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1.\u5f00\u59cb\u5b89\u88c5\u5305<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>pip install requests\n# \u6839\u636e\u6587\u4ef6\u5b89\u88c5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6279\u91cf\u5b89\u88c5\u3002\npip install -r requirements.txt\n# \u79bb\u7ebf\u5b89\u88c5\u5305,\u5b89\u88c5whl,\u5b9e\u9645\u4e0a\u5b89\u88c5tar.gz\u4e5f\u53ef\u4ee5\npip install .\/tmp\/requestxxxx.whl<\/code><\/code><\/pre>\n\n\n\n<p>requirements.txt \u8fd9\u4e2a\u662f\u4e00\u4e2a\u5305\u542b\u5305\u540d\u548c\u7248\u672c\u53f7\u7684\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u5347\u7ea7\u5b89\u88c5\u5305<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install --upgrade requests<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u5378\u8f7d\u5305<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>pip uninstall requests<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u5217\u51fa\u5df2\u5b89\u88c5\u5305<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>pip list<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u67e5\u770b\u5305\u4fe1\u606f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4f1a\u663e\u793a\u4e00\u4e9b\u4f9d\u8d56\u4fe1\u606f\npip show requests<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">6.\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u52a0\u901f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4f7f\u7528\u8c46\u74e3\u955c\u50cf\u52a0\u901f\u4e0b\u8f7drequests\u5305\npip install -i https:\/\/pypi.douban.com\/simple\/ requests<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">7. \u4e0b\u8f7d\u5305<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06requests\u5305\u4e0b\u8f7d\u5b89\u88c5\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u7684tmp\u76ee\u5f55\u4e2d\n# \u8fd9\u4e2a\u4e3b\u8981\u7528\u5728\u9700\u8981\u79bb\u7ebf\u5b89\u88c5\u5305\u7684\u60c5\u51b5\u4e0b\uff0c\u6bd4\u5982\u751f\u4ea7\u73af\u5883\u6ca1\u6709\u7f51\u7edc\npip download requests -d .\/tmp<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">8.\u68c0\u67e5\u5305\u7684\u4f9d\u8d56\u5173\u7cfb<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5982\u679c\u6b63\u5e38\uff0c\u5219\u4f1a\u63d0\u793a\uff1aNo broken requirements found.\npip check<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e00\u4e2a\u95ee\u9898\u70b9\uff1apip check \u662f\u5426\u8054\u7f51\uff1f<\/h4>\n\n\n\n<p>\u56de\u7b54\u662f\uff1a\u4e0d\u8054\u7f51<br>\u9002\u7528\u573a\u666f\u662f\u4e0d\u662f\u79bb\u7ebf\u5b89\u88c5\u5305\u7684\u60c5\u51b5\u4e0b\uff0c\u56e0\u4e3a\u6b63\u5e38\u8054\u7f51\u5b89\u88c5\u90fd\u4f1a\u81ea\u52a8\u5339\u914d\u4f9d\u8d56\u7684\u3002\u5728\u5305\u4fe1\u606f\u91cc\u9762\uff0c\u6709\u76f8\u5173\u7684\u4f9d\u8d56\u4fe1\u606f\u8bf4\u660e\u3002\u4f7f\u7528pip show\u4f1a\u770b\u5230\u3002\u4f46\u662fpip show\u663e\u793a\u7684require\u53ea\u662f\u63d0\u793a\u9700\u8981\u54ea\u4e2a\u5305\uff0c\u5e76\u672a\u8bf4\u660e\u7248\u672c\u8981\u6c42\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. \u751f\u6210wheel\u6587\u4ef6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">9.1 \u8054\u7f51\u751f\u6210whl\u6587\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06six\u5305\u751f\u6210whl\u6587\u4ef6\uff0c\u9700\u8981\u8054\u7f51\u4e0b\u8f7d\u624d\u884c\uff0c\u79bb\u7ebf\u73af\u5883\u4e0d\u884c\u3002\npip wheel six --wheel=.\/wheelfile\n# \u5982\u679c\u662f\u5185\u7f51\u6e90\uff0c\u53ef\u4ee5\u81ea\u5df1\u52a0\uff0c\u540c\u65f6\u6dfb\u52a0\u7248\u672c\u53f7,http\uff0c\u9700\u8981\u52a0--trusted-host\npip wheel six==1.10.0 --wheel=.\/wheelfile -i http:\/\/ xxx --trusted-host xxxx\n# \u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u751f\u6210\uff0c\u5728wheelfile\u76ee\u5f55\u4e2d\u751f\u6210whl\u6587\u4ef6\npip wheel six==1.10.0 -i https:\/\/pypi.douban.com\/simple --wheel-dir=.\/wheelfile<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u9700\u8981\u6dfb\u52a0&#8211;trusted-host\u7684\u60c5\u51b5<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528http\u6e90\uff0c\u4f1a\u53d1\u751f\u4e2d\u95f4\u4eba\u653b\u51fb\uff0cpip\u4e0d\u4fe1\u4efb<\/li>\n\n\n\n<li>\u4f7f\u7528https\uff0c\u53ef\u80fd\u7684\u60c5\u51b5\n<ul class=\"wp-block-list\">\n<li>\u81ea\u7b7e\u540d\u8bc1\u4e66<\/li>\n\n\n\n<li>\u8bc1\u4e66\u8fc7\u671f\u6216\u672a\u88ab\u4fe1\u4efb<\/li>\n\n\n\n<li>\u79c1\u6709CA\u7b7e\u53d1\u7684\u8bc1\u4e66<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">9.2 \u79bb\u7ebf\u6587\u4ef6\u751f\u6210whl\u6587\u4ef6<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528pip\u7f13\u5b58\u751f\u6210whl\u6587\u4ef6<\/h4>\n\n\n\n<p>\u5982\u679c\u4e4b\u524d\u6709\u4e0b\u8f7d\u8fc7\uff0c\u4e14\u6ca1\u6709\u4f7f\u7528<code>pip cache purge<\/code>\u6e05\u7406\u8fc7pip\u7f13\u5b58\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528\u3002<code>pip<\/code> \u9ed8\u8ba4\u7f13\u5b58\u8def\u5f84\u901a\u5e38\u4f4d\u4e8e <code>~\/.cache\/pip<\/code> \u6216\u8005 <code>%LOCALAPPDATA%\\pip\\Cache<\/code>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5f85\u89e3\u51b3<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528\u6e90\u7801\u751f\u6210whl\u6587\u4ef6<\/h4>\n\n\n\n<h1 class=\"wp-block-heading\">\u5f85\u89e3\u51b3 \u5982\u4f55\u914d\u7f6epip\u6e90\uff1f\u5728centos\u4e2d\u3002<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>pip wheel pandas-2.1.0.tar.gz --wheel-dir=.\/wheelfile --no-deps<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">10.\u9879\u76ee\u8fc1\u79fb\u5230\u79bb\u7ebf\u73af\u5883<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c06\u5df2\u5b89\u88c5\u7684\u5305\u53ca\u7248\u672c\u53f7\uff0c\u5bfc\u51fa\u81f3\u6587\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip freeze &gt; requirements.txt<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8054\u7f51\u60c5\u51b5\u4e0b\uff0c\u53ef\u76f4\u63a5\u6839\u636erequirements.txt\u5b89\u88c5<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install -r requirements<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6839\u636erequirements.txt\u4e0b\u8f7d\u79bb\u7ebf\u5305<\/h3>\n\n\n\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u6839\u636erequirements.txt\u4e2d\u7684\u5305\u4e0b\u8f7d\u597d\u6240\u6709\u4f60\u9700\u8981\u4f7f\u7528\u7684\u5305\uff0c\u7136\u540e\u590d\u5236\u5230\u4f60\u8981\u5b89\u88c5\u7684\u673a\u5668\u4e0a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip download -r requirements.txt -d .\/wheelfile<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u79bb\u7ebf\u5b89\u88c5\u76f8\u5173\u7684\u5305<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install --no-index --find-links=.\/pkg -r requirements.txt<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u7684\u6e90\u6709\u95ee\u9898\uff0c\u53ef\u4ee5\u589e\u52a0\u4e00\u4e2a&#8211;trusted-host\u53c2\u6570<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e00\u4e9b\u8865\u5145\u8bf4\u660e\uff1a<\/h4>\n\n\n\n<p>\u4f7f\u7528\u8fd9\u79cd\u60c5\u51b5\u5b89\u88c5\uff0c\u4e00\u822c\u4f1a\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u907f\u514d\u7834\u574f\u673a\u5668\u672c\u8eab\u7684python\u73af\u5883\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u521b\u5efa\u65b0\u7684\u865a\u62df\u73af\u5883envname\u662f\u865a\u62df\u73af\u5883\u540d\u79f0\uff0c\u4f1a\u751f\u6210\u4e00\u4e2a\u8fd9\u4e2a\u540d\u79f0\u7684\u76ee\u5f55\npython -m venv envname\n#\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u4e4b\u540e\uff0c\u518d\u4f7f\u7528pip\u5b89\u88c5\nsource envname\/bin\/activate<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5f00\u59cb\u5b89\u88c5\u5305 requirements.txt \u8fd9\u4e2a\u662f\u4e00\u4e2a\u5305\u542b\u5305\u540d\u548c\u7248\u672c\u53f7\u7684\u76f8\u5173\u4fe1\u606f\u3002 2.\u5347\u7ea7\u5b89\u88c5\u5305 3. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[44,7,45],"class_list":["post-204","post","type-post","status-publish","format-standard","hentry","category-unclassified","tag-pip","tag-python","tag-45"],"_links":{"self":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204"}],"version-history":[{"count":1,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":205,"href":"https:\/\/daogu.work\/index.php?rest_route=\/wp\/v2\/posts\/204\/revisions\/205"}],"wp:attachment":[{"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daogu.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}