{"id":932506,"date":"2024-12-26T17:59:21","date_gmt":"2024-12-26T09:59:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/932506.html"},"modified":"2024-12-26T17:59:23","modified_gmt":"2024-12-26T09:59:23","slug":"python%e5%ba%93%e5%a6%82%e4%bd%95%e5%88%a0%e9%99%a4","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/932506.html","title":{"rendered":"python\u5e93\u5982\u4f55\u5220\u9664"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070332\/844a451b-83d6-498c-a3b2-52a8f919f8fd.webp\" alt=\"python\u5e93\u5982\u4f55\u5220\u9664\" \/><\/p>\n<p><p> <strong>\u8981\u5220\u9664Python\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u3001\u624b\u52a8\u5220\u9664\u6587\u4ef6\u5939\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528pip\u547d\u4ee4\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u662fPython\u7684\u5305\u7ba1\u7406\u5668\uff0c\u652f\u6301\u5927\u591a\u6570\u64cd\u4f5c\u7cfb\u7edf\u3002\u4ee5\u4e0b\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684\u4e00\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528pip\u547d\u4ee4\u5220\u9664Python\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u547d\u4ee4\u5220\u9664Python\u5e93\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165<code>pip uninstall package_name<\/code>\uff0c\u5176\u4e2d<code>package_name<\/code>\u662f\u4f60\u60f3\u8981\u5220\u9664\u7684\u5e93\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60f3\u8981\u5220\u9664\u540d\u4e3a<code>requests<\/code>\u7684\u5e93\uff0c\u53ea\u9700\u8f93\u5165<code>pip uninstall requests<\/code>\u3002\u7cfb\u7edf\u4f1a\u63d0\u793a\u4f60\u786e\u8ba4\u5378\u8f7d\u64cd\u4f5c\uff0c\u8f93\u5165\u201cy\u201d\u540e\uff0cpip\u4f1a\u81ea\u52a8\u5220\u9664\u8be5\u5e93\u53ca\u5176\u76f8\u5173\u6587\u4ef6\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6240\u6709\u901a\u8fc7pip\u5b89\u88c5\u7684\u5e93\uff0c\u5e76\u4e14\u80fd\u591f\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u9632\u6b62\u51fa\u73b0\u5e93\u7f3a\u5931\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u4e00\u3001\u4f7f\u7528PIP\u547d\u4ee4\u5220\u9664<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u547d\u4ee4\u5220\u9664Python\u5e93\u662f\u6700\u76f4\u63a5\u548c\u5e38\u7528\u7684\u65b9\u6cd5\u3002pip\u662fPython\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u5141\u8bb8\u7528\u6237\u8f7b\u677e\u5730\u5b89\u88c5\u548c\u7ba1\u7406Python\u8f6f\u4ef6\u5305\u3002\u8981\u4f7f\u7528pip\u5220\u9664\u5e93\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5pip\uff0c\u5e76\u4e14\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5PIP\u5b89\u88c5<\/strong><br \/>\u9996\u5148\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165<code>pip --version<\/code>\u4ee5\u786e\u8ba4pip\u5df2\u7ecf\u5b89\u88c5\u5e76\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u5982\u679c\u547d\u4ee4\u8fd4\u56depip\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8868\u793apip\u5df2\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5220\u9664\u5e93<\/strong><br \/>\u8f93\u5165<code>pip uninstall package_name<\/code>\uff0c\u5176\u4e2d<code>package_name<\/code>\u662f\u9700\u8981\u5220\u9664\u7684\u5e93\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u8981\u5220\u9664<code>numpy<\/code>\u5e93\uff0c\u53ef\u4ee5\u8f93\u5165<code>pip uninstall numpy<\/code>\u3002pip\u5c06\u4f1a\u63d0\u793a\u786e\u8ba4\u5378\u8f7d\u64cd\u4f5c\uff0c\u8f93\u5165\u201cy\u201d\u786e\u8ba4\u5220\u9664\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6\u5939<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5220\u9664\u5e93\u6587\u4ef6\u5939\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u624b\u52a8\u65b9\u5f0f\u5b89\u88c5\u7684\u5e93\u6216\u8005\u51fa\u73b0\u4e86pip\u65e0\u6cd5\u6b63\u5e38\u5378\u8f7d\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u627e\u5230\u5e93\u5b89\u88c5\u4f4d\u7f6e<\/strong><br \/>\u901a\u5e38\uff0cPython\u5e93\u5b89\u88c5\u5728Python\u73af\u5883\u7684<code>site-packages<\/code>\u76ee\u5f55\u4e2d\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884cPython\uff0c\u8f93\u5165<code>import package_name<\/code>\uff0c\u7136\u540e<code>package_name.__file__<\/code>\uff0c\u4ee5\u83b7\u53d6\u5e93\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5220\u9664\u5e93\u6587\u4ef6\u5939<\/strong><br \/>\u627e\u5230\u5e93\u7684\u6587\u4ef6\u5939\u540e\uff0c\u76f4\u63a5\u5220\u9664\u8be5\u6587\u4ef6\u5939\u5373\u53ef\u5b8c\u6210\u5378\u8f7d\u3002\u6ce8\u610f\uff0c\u5728\u8fdb\u884c\u624b\u52a8\u5220\u9664\u64cd\u4f5c\u65f6\uff0c\u8981\u786e\u4fdd\u6ca1\u6709\u5176\u4ed6\u7a0b\u5e8f\u6b63\u5728\u4f7f\u7528\u8be5\u5e93\uff0c\u4ee5\u514d\u53d1\u751f\u6587\u4ef6\u9501\u5b9a\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u5e93<\/p>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u4e2d\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\u7684\u5de5\u5177\uff0c\u80fd\u591f\u907f\u514d\u5168\u5c40\u5b89\u88c5\u5e93\u65f6\u7684\u51b2\u7a81\u95ee\u9898\u3002\u901a\u8fc7\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5b89\u88c5\u548c\u5220\u9664\u5e93\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u9879\u76ee\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><br \/>\u4f7f\u7528\u547d\u4ee4<code>python -m venv env_name<\/code>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u5176\u4e2d<code>env_name<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u6240\u6709\u7684\u5305\u5b89\u88c5\u548c\u5220\u9664\u64cd\u4f5c\u90fd\u5c06\u53ea\u5f71\u54cd\u8be5\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5220\u9664\u5e93<\/strong><br \/>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f7f\u7528\u4e0e\u5168\u5c40\u73af\u5883\u76f8\u540c\u7684<code>pip uninstall package_name<\/code>\u547d\u4ee4\u5220\u9664\u5e93\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5176\u4ed6\u9879\u76ee\u7684\u4f9d\u8d56\u4e0d\u53d7\u5f71\u54cd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u6709\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u66f4\u9ad8\u7ea7\u7684\u5305\u7ba1\u7406\u5de5\u5177\u6765\u7ba1\u7406Python\u5e93\u3002\u4f8b\u5982Anaconda\u3001Poetry\u7b49\u5de5\u5177\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u9002\u5408\u9700\u8981\u7ba1\u7406\u591a\u4e2a\u9879\u76ee\u4f9d\u8d56\u7684\u7528\u6237\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Conda<\/strong><br \/>\u5982\u679c\u4f7f\u7528Anaconda\u4f5c\u4e3aPython\u53d1\u884c\u7248\uff0c\u53ef\u4ee5\u4f7f\u7528<code>conda uninstall package_name<\/code>\u547d\u4ee4\u6765\u5220\u9664\u5e93\u3002Conda\u662fAnaconda\u7684\u5305\u7ba1\u7406\u5668\uff0c\u63d0\u4f9b\u4e86\u7c7b\u4f3cpip\u7684\u529f\u80fd\uff0c\u4f46\u652f\u6301\u66f4\u591a\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\u548c\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Poetry<\/strong><br \/>Poetry\u662f\u4e00\u79cd\u73b0\u4ee3\u7684Python\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u652f\u6301\u4f9d\u8d56\u7ba1\u7406\u548c\u9879\u76ee\u6253\u5305\u7b49\u529f\u80fd\u3002\u8981\u4f7f\u7528Poetry\u5220\u9664\u5e93\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c<code>poetry remove package_name<\/code>\u547d\u4ee4\u3002Poetry\u4f1a\u81ea\u52a8\u66f4\u65b0\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0c\u5220\u9664Python\u5e93\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0c\u4f7f\u7528pip\u662f\u6700\u7b80\u5355\u548c\u76f4\u63a5\u7684\u65b9\u5f0f\uff0c\u800c\u5bf9\u4e8e\u9700\u8981\u7ba1\u7406\u590d\u6742\u4f9d\u8d56\u7684\u9879\u76ee\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u6216\u9ad8\u7ea7\u5305\u7ba1\u7406\u5de5\u5177\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u6ce8\u610f\u5904\u7406\u597d\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ee5\u514d\u5f71\u54cd\u5176\u4ed6\u9879\u76ee\u7684\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5378\u8f7d\u4e0d\u518d\u9700\u8981\u7684\u5e93\uff1f<\/strong><br \/>\u8981\u5378\u8f7d\u4e0d\u518d\u9700\u8981\u7684Python\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u3002\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>pip uninstall \u5e93\u540d<\/code>\uff0c\u5176\u4e2d\u201c\u5e93\u540d\u201d\u662f\u4f60\u60f3\u8981\u5220\u9664\u7684\u5e93\u7684\u540d\u79f0\u3002\u7cfb\u7edf\u4f1a\u63d0\u793a\u4f60\u786e\u8ba4\u5220\u9664\uff0c\u8f93\u5165\u201cy\u201d\u5373\u53ef\u5b8c\u6210\u5378\u8f7d\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684\u5e93\u3002<\/p>\n<p><strong>\u5728\u4f7f\u7528\u865a\u62df\u73af\u5883\u65f6\u5982\u4f55\u5220\u9664\u5e93\uff1f<\/strong><br \/>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5220\u9664\u5e93\u7684\u6b65\u9aa4\u4e0e\u5168\u5c40\u73af\u5883\u76f8\u4f3c\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u865a\u62df\u73af\u5883\u3002\u7136\u540e\u4f7f\u7528<code>pip uninstall \u5e93\u540d<\/code>\u547d\u4ee4\u8fdb\u884c\u5378\u8f7d\u3002\u8fd9\u6837\uff0c\u4f60\u53ef\u4ee5\u786e\u4fdd\u53ea\u5220\u9664\u5f53\u524d\u865a\u62df\u73af\u5883\u4e2d\u7684\u5e93\uff0c\u800c\u4e0d\u5f71\u54cd\u5168\u5c40\u73af\u5883\u4e2d\u7684\u5176\u4ed6\u5e93\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u7ba1\u7406\u548c\u5220\u9664Python\u5e93\uff1f<\/strong><br \/>\u9664\u4e86\u4f7f\u7528pip\uff0c\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7ba1\u7406Python\u5e93\u3002\u4f8b\u5982\uff0cAnaconda\u7528\u6237\u53ef\u4ee5\u4f7f\u7528<code>conda remove \u5e93\u540d<\/code>\u547d\u4ee4\u6765\u5378\u8f7d\u5e93\u3002\u6b64\u5916\uff0c\u6709\u4e9b\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982PyCharm\u4e5f\u63d0\u4f9b\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u5141\u8bb8\u4f60\u65b9\u4fbf\u5730\u67e5\u770b\u548c\u5220\u9664\u5b89\u88c5\u7684\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5220\u9664Python\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u3001\u624b\u52a8\u5220\u9664\u6587\u4ef6\u5939\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u3002\u5176\u4e2d\uff0c\u4f7f\u7528pip\u547d\u4ee4\u662f [&hellip;]","protected":false},"author":3,"featured_media":932509,"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\/932506"}],"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=932506"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/932506\/revisions"}],"predecessor-version":[{"id":932510,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/932506\/revisions\/932510"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/932509"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=932506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=932506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=932506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}