{"id":176986,"date":"2024-05-08T19:21:38","date_gmt":"2024-05-08T11:21:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/176986.html"},"modified":"2024-05-08T19:21:44","modified_gmt":"2024-05-08T11:21:44","slug":"python%e4%b8%ad%e7%94%a8pip%e5%ae%89%e8%a3%85jieba%e5%ba%93%ef%bc%8c%e4%b8%80%e7%9b%b4%e5%87%ba%e9%94%99%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/176986.html","title":{"rendered":"python\u4e2d\u7528pip\u5b89\u88c5jieba\u5e93\uff0c\u4e00\u76f4\u51fa\u9519\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27060827\/d34809f2-aa7f-40ac-8071-433e0b70db1e.webp\" alt=\"python\u4e2d\u7528pip\u5b89\u88c5jieba\u5e93\uff0c\u4e00\u76f4\u51fa\u9519\u600e\u4e48\u89e3\u51b3\" \/><\/p>\n<p><p>Python\u4e2d\u4f7f\u7528pip\u5b89\u88c5jieba\u5e93\u65f6\u53ef\u80fd\u9047\u5230\u7684\u9519\u8bef\u901a\u5e38\u5305\u62ec\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3001\u6743\u9650\u4e0d\u8db3\u3001pip\u7248\u672c\u4e0d\u517c\u5bb9<strong>\u6216\u4f9d\u8d56\u5173\u7cfb\u51b2\u7a81<\/strong>\u3002\u5bf9\u4e8e\u8fd9\u4e9b\u95ee\u9898\uff0c\u9996\u5148\u9a8c\u8bc1\u4f60\u7684\u7f51\u7edc\u8fde\u63a5\u662f\u5426\u7545\u901a\uff0c\u5176\u6b21\u786e\u4fdd\u4f60\u62e5\u6709\u5b89\u88c5jieba\u5e93\u6240\u9700\u7684\u6743\u9650\u3002\u5982\u679c\u95ee\u9898\u4f9d\u65e7\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u65b0pip\u5230\u6700\u65b0\u7248\u672c\u6216\u662f\u68c0\u67e5\u4f9d\u8d56\u5e93\u4e4b\u95f4\u662f\u5426\u5b58\u5728\u51b2\u7a81\u3002<strong>\u66f4\u65b0pip\u901a\u5e38\u662f\u89e3\u51b3\u5b89\u88c5\u95ee\u9898\u7684\u6709\u6548\u65b9\u6cd5<\/strong>\uff0c\u6267\u884c\u547d\u4ee4 <code>pip install --upgrade pip<\/code> \u5373\u53ef\u66f4\u65b0\u3002\u8fd8\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u5408\u9002\u7684pip\u7248\u672c\u6765\u5339\u914d\u4f60\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u786e\u4fdd\u7f51\u7edc\u8fde\u63a5\u6b63\u5e38<\/h3>\n<\/p>\n<p><p>\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u662f\u5b89\u88c5Python\u5305\u65f6\u5e38\u9047\u5230\u7684\u95ee\u9898\u3002\u786e\u4fdd\u4f60\u7684\u7535\u8111\u6216\u670d\u52a1\u5668\u53ef\u4ee5\u8bbf\u95eePython\u5305\u7ba1\u7406\u7cfb\u7edfPyPI\u3002\u5982\u679c\u4f60\u5728\u4e2d\u56fd\u5927\u9646\u4f7f\u7528\uff0c\u53ef\u80fd\u9700\u8981\u914d\u7f6e\u4ee3\u7406\u6216\u4f7f\u7528\u56fd\u5185\u7684PyPI\u955c\u50cf\uff0c\u5982\u963f\u91cc\u4e91\u3001\u6e05\u534e\u5927\u5b66\u7b49\u63d0\u4f9b\u7684\u955c\u50cf\u670d\u52a1\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u68c0\u67e5\u5b89\u88c5\u6743\u9650<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5728\u5b89\u88c5\u65f6\u6536\u5230\u6743\u9650\u9519\u8bef\uff0c\u53ef\u80fd\u9700\u8981\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u5b89\u88c5\u547d\u4ee4\u6216\u5728Linux\u7cfb\u7edf\u4e2d\u4f7f\u7528<code>sudo<\/code>\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528<code>sudo pip install jieba<\/code>\u547d\u4ee4\u6765\u5b89\u88c5jieba\u5e93\u3002\u4f46\u8981\u6ce8\u610f\uff0c\u6ee5\u7528root\u6743\u9650\u53ef\u80fd\u5e26\u6765\u5b89\u5168\u98ce\u9669\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5347\u7ea7pip\u81f3\u6700\u65b0\u7248\u672c<\/h3>\n<\/p>\n<p><p>pip\u7684\u67d0\u4e9b\u65e7\u7248\u672c\u53ef\u80fd\u4e0d\u652f\u6301\u6700\u65b0\u7684\u5305\u6216\u6709\u4e00\u4e9b\u5df2\u77e5\u7684bug\u3002\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0pip\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6709\u65f6\u9700\u8981\u533a\u5206python\u7248\u672c\uff0c\u5982\u679c\u7cfb\u7edf\u5b89\u88c5\u6709\u591a\u4e2aPython\u7248\u672c\uff0c\u9700\u8981\u6307\u5b9a\u4f7f\u7528\u7684\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u6e05\u7406\u672c\u5730\u7f13\u5b58<\/h3>\n<\/p>\n<p><p>\u6709\u65f6pip\u4f1a\u4f7f\u7528\u7f13\u5b58\u4e2d\u635f\u574f\u7684\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u6e05\u7406pip\u7684\u7f13\u5b58\u518d\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip cache purge<\/p>\n<p>pip install jieba<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u68c0\u67e5Python\u548cpip\u7248\u672c\u517c\u5bb9\u6027<\/h3>\n<\/p>\n<p><p>\u786e\u8ba4\u4f60\u7684Python\u7248\u672c\u548cpip\u7248\u672c\u662f\u5426\u517c\u5bb9\u3002jieba\u5e93\u8981\u6c42Python 2.7\u6216Python 3.4\u4ee5\u4e0a\u7248\u672c\uff0c\u6240\u4ee5\u9700\u8981\u4fdd\u8bc1Python\u7684\u7248\u672c\u6ee1\u8db3\u8be5\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5c1d\u8bd5\u4e0d\u540c\u7684\u5b89\u88c5\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u90fd\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u4e0d\u540c\u7684\u5b89\u88c5\u547d\u4ee4\uff0c\u4f8b\u5982\u4f7f\u7528<code>--no-cache-dir<\/code>\u6807\u8bb0\u6765\u907f\u514d\u4f7f\u7528\u7f13\u5b58\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --no-cache-dir jieba<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5c1d\u8bd5\u6307\u5b9a\u4e00\u4e2a\u7248\u672c\u53f7\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install jieba==0.42.1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u68c0\u67e5\u4f9d\u8d56\u5e93\u548c\u7cfb\u7edf\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u9519\u8bef\u53ef\u80fd\u7531\u73af\u5883\u4e2d\u5176\u4ed6\u5e93\u7684\u51b2\u7a81\u5f15\u8d77\u3002\u67e5\u770b\u9519\u8bef\u4fe1\u606f\uff0c\u5224\u65ad\u662f\u5426\u662f\u7531\u4e8e\u67d0\u4e2a\u4f9d\u8d56\u5305\u5bfc\u81f4\u7684\u95ee\u9898\u3002\u4f60\u53ef\u80fd\u9700\u8981\u5148\u5347\u7ea7\u6216\u964d\u7ea7\u90a3\u4e9b\u5305\u3002\u540c\u65f6\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u662f\u5426\u6709\u7279\u5b9a\u4e8e\u5e73\u53f0\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u5b89\u88c5\u65f6\u6307\u5b9a\u955c\u50cf\u6e90<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5728\u56fd\u5185\uff0c\u53ef\u80fd\u7531\u4e8e\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u65e0\u6cd5\u8bbf\u95eePyPI\uff0c\u8fd9\u65f6\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u56fd\u5185\u6e90\u6765\u52a0\u901f\u5b89\u88c5\u8fc7\u7a0b\u3002\u5982\u4f7f\u7528\u6e05\u534e\u5927\u5b66\u63d0\u4f9b\u7684PyPI\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple jieba<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u624b\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4e0a\u8ff0\u6240\u6709\u65b9\u6cd5\u90fd\u672a\u80fd\u89e3\u51b3\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u4eceGitHub\u6216PyPI\u624b\u52a8\u4e0b\u8f7djieba\u7684whl\u6587\u4ef6\u6216\u6e90\u4ee3\u7801\u5305\uff0c\u7136\u540e\u624b\u52a8\u5b89\u88c5\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u5207\u6362\u5230\u4e0b\u8f7d\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528pip\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install jieba-*.whl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u76f4\u63a5\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">tar xzf jieba-*.tar.gz<\/p>\n<p>cd jieba-*<\/p>\n<p>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u5982\u679c\u4efb\u4f55\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u67e5\u770bpip\u7684\u9519\u8bef\u8f93\u51fa\u3001\u641c\u7d22\u95ee\u9898\u5173\u952e\u8bcd\u6216\u8be2\u95ee\u5f00\u6e90\u793e\u533a\u6765\u83b7\u53d6\u66f4\u5177\u4f53\u7684\u89e3\u7b54\u3002\u8bb0\u4f4f\uff0c\u95ee\u9898\u7684\u89e3\u51b3\u901a\u5e38\u9700\u8981\u8010\u5fc3\u548c\u4e00\u4e9b\u8c03\u8bd5\u6280\u5de7\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u95ee\u98981\uff1a\u4e3a\u4ec0\u4e48\u6211\u5728\u4f7f\u7528pip\u5b89\u88c5jieba\u5e93\u65f6\u4e00\u76f4\u51fa\u9519\uff1f<\/strong><br \/>\n\u5728\u4f7f\u7528pip\u5b89\u88c5jieba\u5e93\u65f6\u51fa\u73b0\u9519\u8bef\u53ef\u80fd\u6709\u591a\u79cd\u539f\u56e0\u3002\u5e38\u89c1\u7684\u95ee\u9898\u53ef\u80fd\u5305\u62ec\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3001\u6743\u9650\u95ee\u9898\u3001\u7248\u672c\u51b2\u7a81\u7b49\u3002\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u7684\u65b9\u6cd5\u53ef\u4ee5\u662f\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u3001\u4ee5\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884c\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u6216\u8005\u4f7f\u7528\u9002\u5f53\u7684\u53c2\u6570\u6765\u6307\u5b9a\u8981\u5b89\u88c5\u7684\u7248\u672c\u3002<\/p>\n<p><strong>\u95ee\u98982\uff1a\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5b89\u88c5jieba\u5e93\uff0c\u800c\u4e0d\u4f7f\u7528pip\uff1f<\/strong><br \/>\n\u9664\u4e86\u4f7f\u7528pip\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5b89\u88c5jieba\u5e93\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528conda\u8fdb\u884c\u5b89\u88c5\uff0cconda\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\uff0c\u5e76\u65b9\u4fbf\u5730\u5b89\u88c5\u7b2c\u4e09\u65b9\u5e93\u3002\u53e6\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u624b\u52a8\u4e0b\u8f7djieba\u5e93\u7684\u6e90\u4ee3\u7801\uff0c\u7136\u540e\u5728\u672c\u5730\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u95ee\u98983\uff1a\u5728\u6211\u6210\u529f\u5b89\u88c5jieba\u5e93\u4e4b\u540e\uff0c\u5982\u4f55\u4f7f\u7528\u5b83\uff1f<\/strong><br \/>\n\u5b89\u88c5jieba\u5e93\u540e\uff0c\u4f60\u53ef\u4ee5\u5728Python\u811a\u672c\u4e2d\u4f7f\u7528\u5b83\u6765\u8fdb\u884c\u4e2d\u6587\u5206\u8bcd\u548c\u5176\u4ed6\u6587\u672c\u5904\u7406\u4efb\u52a1\u3002\u5728\u4f7f\u7528\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5bfc\u5165jieba\u5e93\uff0c\u7136\u540e\u8c03\u7528\u76f8\u5173\u7684\u51fd\u6570\u548c\u65b9\u6cd5\u6765\u5b9e\u73b0\u4f60\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528jieba.cut()\u51fd\u6570\u5bf9\u6587\u672c\u8fdb\u884c\u5206\u8bcd\uff0c\u4f7f\u7528jieba.lcut()\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5206\u8bcd\u7ed3\u679c\u7684\u5217\u8868\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528jieba.add_word()\u51fd\u6570\u6765\u6dfb\u52a0\u81ea\u5b9a\u4e49\u8bcd\u5178\uff0c\u63d0\u9ad8\u5206\u8bcd\u6548\u679c\u3002\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u9700\u6c42\uff0c\u4f60\u8fd8\u53ef\u4ee5\u67e5\u9605jieba\u5e93\u7684\u5b98\u65b9\u6587\u6863\u6216\u5bfb\u6c42\u76f8\u5173\u7684\u6559\u7a0b\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u4f7f\u7528pip\u5b89\u88c5jieba\u5e93\u65f6\u53ef\u80fd\u9047\u5230\u7684\u9519\u8bef\u901a\u5e38\u5305\u62ec\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3001\u6743\u9650\u4e0d\u8db3\u3001pip\u7248\u672c\u4e0d\u517c\u5bb9\u6216\u4f9d\u8d56 [&hellip;]","protected":false},"author":3,"featured_media":176993,"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\/176986"}],"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=176986"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/176986\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/176993"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=176986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=176986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=176986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}