转:https://www.cnblogs.com/jiawen010/p/10314542.html
通过pycharm创建Django项目是出现如下错误
AttributeError: module 'pip' has no attribute 'main'
环境信息:pycharm2017.3.1(Professional Edition)、python3.6.5 (64位)、pip10.0.1、Django2.0.5
错误原因:由于pip 10版本中没有main(),如果在不降级的情况下,修改这个文件
找到pycharm安装目录下的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: # import pip 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: # import pip try: from pip._internal import main except Exception: from pip import main except ImportError: error_no_pip() return main(['uninstall', '-y'] + pkgs)