AttributeError: Module Pip has no attribute 'main'

后端 未结 16 1272
滥情空心
滥情空心 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:23
    python3 -m pip install --user --upgrade pip==9.0.3
    

    pip issue: rollback

    0 讨论(0)
  • 2020-11-29 01:23

    This helps me, https://pip.pypa.io/en/stable/installing/

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python get-pip.py
    

    If you are using python3 and not set it default. do this,

    python3 get-pip.py
    

    It works for me.

    0 讨论(0)
  • 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])
    
    0 讨论(0)
  • 2020-11-29 01:29

    It appears that pip did a refactor and moved main to internal. There is a comprehensive discussion about it here: https://github.com/pypa/pip/issues/5240

    A workaround for me was to change

    import pip
    pip.main(...)
    

    to

    from pip._internal import main
    main(...)
    

    I recommend reading through the discussion, I'm not sure this is the best approach, but it worked for my purposes.

    0 讨论(0)
提交回复
热议问题