AttributeError: Module Pip has no attribute 'main'

后端 未结 16 1412
滥情空心
滥情空心 2020-11-29 00:53

I am trying to build the python api for an open source project called Zulip and I keep running into the same issue as indicated by the screenshot below.

I am running

16条回答
  •  旧巷少年郎
    2020-11-29 01:26

    My solution is to check the version number of pip and use the import the correct main function correctly

        import pip
    
        if int(pip.__version__.split('.')[0])>9:
            from pip._internal import main
        else:
            from pip import main
        def install(package):
            main(['install', package])
    

提交回复
热议问题