-
错误报告:
Traceback (most recent call last):
File "..../Contents/helpers/packaging_tool.py", line 192, in main
retcode = do_install(pkgs)
File "....//Contents/helpers/packaging_tool.py", line 109, in do_install
return pip.main(['install'] + pkgs)
AttributeError: 'module' object has no attribute 'main'错误的文件: packaging_tool.py
-
尝试但未成功的方法:
1,重装系列:重装了Python3.4 不成功,重装了Pycharm2017不成功
2,更新系列:更新了Python3.4->Python3.6不成功,更新pip 9 -> pip 10 不成功
3,解释器系列:新建虚拟Python解释器环境,不成功
-
尝试且成功的方法:
- 成功的方法1:修错误文件方法(推荐使用这个方法)
- 找到 packaging_tool.py 内 这个两个方法(函数),并注释,然后贴上第二段代码
def do_install(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['uninstall', '-y'] + pkgs)
解决问题的代码如下:
def do_install(pkgs):
try:
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['uninstall', '-y'] + pkgs)
- 成功的方法2:更新Pycharm2017到Pycharm2018
- 成功的方法3:使用命令行模式
比如:
I hope it will help you.