解决PyCharm问题:module 'pip' has no attribute 'main'

更新pip之后,PyCharm安装package出现如下报错:

1
module 'pip' has no attribute 'main'

找到安装目录下helpers/packaging_tool.py文件,修改如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def do_install(pkgs):
try:
# import pip
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
# return pip.main(['install'] + pkgs)
return main(['install'] + pkgs)


def do_uninstall(pkgs):
try:
# import pip
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
# return pip.main(['uninstall', '-y'] + pkgs)
return main(['uninstall', '-y'] + pkgs)

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :