{"id":948439,"date":"2024-12-27T00:03:35","date_gmt":"2024-12-26T16:03:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/948439.html"},"modified":"2024-12-27T00:03:37","modified_gmt":"2024-12-26T16:03:37","slug":"%e5%a6%82%e4%bd%95%e6%9b%bf%e6%8d%a2python%e6%ba%90","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/948439.html","title":{"rendered":"\u5982\u4f55\u66ff\u6362python\u6e90"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25083814\/8fa57185-459c-448b-99f0-77e414af166d.webp\" alt=\"\u5982\u4f55\u66ff\u6362python\u6e90\" \/><\/p>\n<p><p> <strong>\u66ff\u6362Python\u6e90\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u4e3b\u8981\u5305\u62ec\u66f4\u6539pip\u6e90\u3001\u66f4\u6539conda\u6e90\u4ee5\u53ca\u624b\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5305\u3002\u66f4\u6539pip\u6e90\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u4fee\u6539pip\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u6c38\u4e45\u6027\u5730\u66ff\u6362Python\u5305\u7ba1\u7406\u5de5\u5177pip\u7684\u9ed8\u8ba4\u6e90\u5730\u5740\u3002\u624b\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5305\u9002\u7528\u4e8e\u7279\u6b8a\u60c5\u51b5\u4e0b\u7684\u9700\u6c42\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u66f4\u6539pip\u6e90\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\uff0c\u539f\u56e0\u662fpip\u662fPython\u6700\u5e38\u7528\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4ecePython\u5b98\u65b9\u7684PyPI\uff08Python Package Index\uff09\u6e90\u4e0b\u8f7d\u5305\u3002\u7136\u800c\uff0c\u7531\u4e8e\u7f51\u7edc\u539f\u56e0\uff0cPyPI\u5728\u67d0\u4e9b\u5730\u533a\u53ef\u80fd\u8bbf\u95ee\u901f\u5ea6\u8f83\u6162\u751a\u81f3\u65e0\u6cd5\u8bbf\u95ee\uff0c\u56e0\u6b64\u66f4\u6539\u4e3a\u56fd\u5185\u955c\u50cf\u6e90\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u66ff\u6362Python\u6e90\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u66f4\u6539PIP\u6e90<\/h2>\n<\/p>\n<p><h3>1\u3001\u4e34\u65f6\u66f4\u6539PIP\u6e90<\/h3>\n<\/p>\n<p><p>\u4e34\u65f6\u66f4\u6539pip\u6e90\u662f\u5728\u5b89\u88c5Python\u5305\u65f6\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u6307\u5b9a\u4e00\u4e2a\u4e0d\u540c\u7684\u6e90\u3002\u8fd9\u4e2a\u65b9\u6cd5\u9002\u7528\u4e8e\u5355\u6b21\u5b89\u88c5\uff0c\u4e0d\u4f1a\u5f71\u54cd\u4ee5\u540e\u5b89\u88c5\u5176\u4ed6\u5305\u7684\u6e90\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install package_name -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u547d\u4ee4\u4e2d\uff0c<code>-i<\/code>\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u65b0\u7684\u6e90\u5730\u5740\uff0c\u8fd9\u91cc\u4f7f\u7528\u7684\u662f\u6e05\u534e\u5927\u5b66\u7684\u955c\u50cf\u6e90\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u6c38\u4e45\u66f4\u6539PIP\u6e90<\/h3>\n<\/p>\n<p><p>\u6c38\u4e45\u66f4\u6539pip\u6e90\u9700\u8981\u4fee\u6539pip\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4f4d\u7f6e\u4e0d\u540c\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Windows<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>pip config set global.index-url https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/code>\u3002<\/li>\n<li><strong>Linux\u548cMacOS<\/strong>\uff1a\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u521b\u5efa\u6216\u4fee\u6539<code>.pip\/pip.conf<\/code>\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/li>\n<\/ul>\n<p><pre><code class=\"language-ini\">[global]<\/p>\n<p>index-url = https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5e38\u7528\u7684\u56fd\u5185\u955c\u50cf\u6e90<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u56fd\u5185\u955c\u50cf\u6e90\u5730\u5740\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6e05\u534e\u5927\u5b66\uff1a<a href=\"https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\">https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/a><\/li>\n<li>\u963f\u91cc\u4e91\uff1a<a href=\"https:\/\/mirrors.aliyun.com\/pypi\/simple\/\">https:\/\/mirrors.aliyun.com\/pypi\/simple\/<\/a><\/li>\n<li>\u8c46\u74e3\uff1a<a href=\"https:\/\/pypi.douban.com\/simple\/\">https:\/\/pypi.douban.com\/simple\/<\/a><\/li>\n<\/ul>\n<p><p>\u8fd9\u4e9b\u955c\u50cf\u6e90\u901a\u5e38\u66f4\u65b0\u8f83\u5feb\uff0c\u4e14\u5728\u56fd\u5185\u8bbf\u95ee\u901f\u5ea6\u66f4\u5feb\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u66f4\u6539CONDA\u6e90<\/h2>\n<\/p>\n<p><p>Conda\u662f\u53e6\u4e00\u4e2a\u6d41\u884c\u7684Python\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u7279\u522b\u662f\u5728\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u79d1\u5b66\u9886\u57df\u3002\u66f4\u6539Conda\u6e90\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u4e34\u65f6\u66f4\u6539CONDA\u6e90<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528conda\u5b89\u88c5\u5305\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u53c2\u6570<code>-c<\/code>\u4e34\u65f6\u66f4\u6539\u6e90\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install package_name -c https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/free\/<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u6c38\u4e45\u66f4\u6539CONDA\u6e90<\/h3>\n<\/p>\n<p><p>\u6c38\u4e45\u66f4\u6539Conda\u6e90\u9700\u8981\u4fee\u6539Conda\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u6dfb\u52a0\u65b0\u7684\u6e90\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda config --add channels https:\/\/mirrors.tuna.tsinghua.edu.cn\/anaconda\/pkgs\/free\/<\/p>\n<p>conda config --set show_channel_urls yes<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u6062\u590d\u9ed8\u8ba4\u6e90<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u6062\u590d\u5230\u9ed8\u8ba4\u6e90\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda config --remove-key channels<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u624b\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5305<\/h2>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u624b\u52a8\u4e0b\u8f7dPython\u5305\uff0c\u7136\u540e\u8fdb\u884c\u5b89\u88c5\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u65e0\u6cd5\u901a\u8fc7pip\u6216conda\u4e0b\u8f7d\u5305\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u4e0b\u8f7d\u5305<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eePyPI\u7f51\u7ad9\u6216\u4f7f\u7528wget\/curl\u547d\u4ee4\u4e0b\u8f7d\u5305\u7684<code>.tar.gz<\/code>\u6216<code>.whl<\/code>\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5b89\u88c5\u5305<\/h3>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u4f7f\u7528pip\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install package_name.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u89e3\u538b<code>.tar.gz<\/code>\u6587\u4ef6\u540e\uff0c\u8fdb\u5165\u76ee\u5f55\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u66ff\u6362Python\u6e90\u53ef\u4ee5\u5927\u5e45\u63d0\u5347\u5305\u4e0b\u8f7d\u901f\u5ea6\uff0c\u7279\u522b\u662f\u5728\u7f51\u7edc\u6761\u4ef6\u4e0d\u4f73\u65f6\u3002<strong>\u65e0\u8bba\u662f\u66f4\u6539pip\u6e90\u3001conda\u6e90\u8fd8\u662f\u624b\u52a8\u4e0b\u8f7d\u5305\uff0c\u90fd\u9700\u8981\u4e86\u89e3\u5404\u81ea\u7684\u914d\u7f6e\u65b9\u6cd5\u548c\u5e38\u7528\u955c\u50cf\u6e90\u3002<\/strong>\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8Python\u5f00\u53d1\u6548\u7387\uff0c\u5e76\u786e\u4fdd\u5f00\u53d1\u73af\u5883\u7684\u7a33\u5b9a\u6027\u548c\u4e00\u81f4\u6027\u3002\u901a\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5e0c\u671b\u60a8\u80fd\u5bf9\u5982\u4f55\u66ff\u6362Python\u6e90\u6709\u4e00\u4e2a\u5168\u9762\u7684\u4e86\u89e3\uff0c\u5e76\u80fd\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u66ff\u6362\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Python\u6e90\u8fdb\u884c\u66ff\u6362\uff1f<\/strong><br \/>\u5728\u66ff\u6362Python\u6e90\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u6e90\u975e\u5e38\u91cd\u8981\u3002\u901a\u5e38\uff0c\u5b98\u65b9\u7684PyPI\u6e90\u662f\u6700\u5e38\u7528\u7684\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u4f1a\u66f4\u5feb\uff0c\u6bd4\u5982\u6e05\u534e\u5927\u5b66\u3001\u963f\u91cc\u4e91\u7b49\u3002\u8fd9\u4e9b\u955c\u50cf\u6e90\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6\uff0c\u7279\u522b\u662f\u5728\u4e2d\u56fd\u5730\u533a\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u7f51\u7edc\u6761\u4ef6\u548c\u9700\u6c42\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u7684\u6e90\u3002<\/p>\n<p><strong>\u66ff\u6362Python\u6e90\u540e\uff0c\u5982\u4f55\u9a8c\u8bc1\u662f\u5426\u6210\u529f\uff1f<\/strong><br \/>\u5b8c\u6210\u6e90\u7684\u66ff\u6362\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6267\u884c<code>pip config get global.index-url<\/code>\u6216<code>pip config get user.index-url<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1\u5f53\u524d\u914d\u7f6e\u7684\u6e90\u5730\u5740\u3002\u5982\u679c\u8fd4\u56de\u7684\u5730\u5740\u4e0e\u60a8\u6240\u8bbe\u7f6e\u7684\u6e90\u4e00\u81f4\uff0c\u5219\u8bf4\u660e\u66ff\u6362\u6210\u529f\u3002\u6b64\u5916\uff0c\u5c1d\u8bd5\u5b89\u88c5\u4e00\u4e2a\u5305\u5e76\u89c2\u5bdf\u4e0b\u8f7d\u901f\u5ea6\uff0c\u4e5f\u53ef\u4ee5\u76f4\u89c2\u5730\u611f\u53d7\u5230\u6e90\u7684\u66ff\u6362\u6548\u679c\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u66ff\u6362\u6e90\u540e\u4ecd\u9047\u5230\u4e0b\u8f7d\u95ee\u9898\uff0c\u5e94\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u5982\u679c\u5728\u66ff\u6362\u6e90\u540e\u4ecd\u7136\u9047\u5230\u4e0b\u8f7d\u901f\u5ea6\u6162\u6216\u4e0b\u8f7d\u5931\u8d25\u7684\u95ee\u9898\uff0c\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u6e05\u7406pip\u7f13\u5b58\uff0c\u901a\u8fc7\u547d\u4ee4<code>pip cache purge<\/code>\u6765\u6e05\u9664\u4e4b\u524d\u7684\u7f13\u5b58\u3002\u540c\u65f6\uff0c\u68c0\u67e5\u60a8\u7684\u7f51\u7edc\u8fde\u63a5\u662f\u5426\u7a33\u5b9a\uff0c\u5e76\u8003\u8651\u4f7f\u7528\u5176\u4ed6\u7684\u955c\u50cf\u6e90\u8fdb\u884c\u5c1d\u8bd5\u3002\u5982\u679c\u95ee\u9898\u6301\u7eed\u5b58\u5728\uff0c\u67e5\u770bPython\u548cpip\u7684\u7248\u672c\u662f\u5426\u4e3a\u6700\u65b0\u7248\u672c\u4e5f\u662f\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\uff0c\u66f4\u65b0\u540e\u518d\u8bd5\u53ef\u80fd\u4f1a\u6709\u6240\u6539\u5584\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u66ff\u6362Python\u6e90\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u4e3b\u8981\u5305\u62ec\u66f4\u6539pip\u6e90\u3001\u66f4\u6539conda\u6e90\u4ee5\u53ca\u624b\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5305\u3002\u66f4\u6539pip\u6e90\u662f\u6700\u5e38 [&hellip;]","protected":false},"author":3,"featured_media":948441,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/948439"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=948439"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/948439\/revisions"}],"predecessor-version":[{"id":948442,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/948439\/revisions\/948442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/948441"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=948439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=948439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=948439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}