{"id":2059,"date":"2023-04-01T21:29:27","date_gmt":"2023-04-01T13:29:27","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2059"},"modified":"2023-04-07T06:05:01","modified_gmt":"2023-04-06T22:05:01","slug":"pycharm-problem-module-pip-has-no-attribute-main","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/pycharm-problem-module-pip-has-no-attribute-main\/","title":{"rendered":"\u89e3\u51b3PyCharm\u95ee\u9898\uff1amodule &#8216;pip&#8217; has no attribute &#8216;main&#8217;"},"content":{"rendered":"<p>\u66f4\u65b0pip\u4e4b\u540e\uff0cPyCharm\u5b89\u88c5package\u51fa\u73b0\u5982\u4e0b\u62a5\u9519\uff1a<\/p>\n<pre><code>module &#039;pip&#039; has no attribute &#039;main&#039;<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u627e\u5230\u5b89\u88c5\u76ee\u5f55\u4e0b<code>helpers\/packaging_tool.py<\/code>\u6587\u4ef6\uff0c\u4fee\u6539\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">def do_install(pkgs):\n    try:\n        # import pip\n        try:\n            from pip._internal import main\n        except Exception:\n            from pip import main\n    except ImportError:\n        error_no_pip()\n    # return pip.main([&#039;install&#039;] + pkgs)\n    return main([&#039;install&#039;] + pkgs)\n\ndef do_uninstall(pkgs):\n    try:\n        # import pip\n        try:\n            from pip._internal import main\n        except Exception:\n            from pip import main\n    except ImportError:\n        error_no_pip()\n    # return pip.main([&#039;uninstall&#039;, &#039;-y&#039;] + pkgs)\n    return main([&#039;uninstall&#039;, &#039;-y&#039;] + pkgs)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u65b0pip\u4e4b\u540e\uff0cPyCharm\u5b89\u88c5package\u51fa\u73b0\u5982\u4e0b\u62a5\u9519\uff1a module &#039;pip&#039;  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[521,520],"class_list":["post-2059","post","type-post","status-publish","format-standard","hentry","category-python","tag-pip","tag-pycharm"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2059"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2059\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}