AttributeError: Module Pip has no attribute 'main'

后端 未结 16 1273
滥情空心
滥情空心 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:15

    To verify whether is your pip installation problem, try using easy_install to install an earlier version of pip:

    easy_install pip==9.0.1
    

    If this succeed, pip should be working now. Then you can go ahead to install any other version of pip you want with:

    pip install pip==10....
    

    Or you can just stay with version 9.0.1, as your project requires version >= 9.0.

    Try building your project again.

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

    First run

    import pip
    pip.__version__
    

    If the result is '10.0.0', then it means that you installed pip successfully
    since pip 10.0.0 doesn't support pip.main() any more, you may find this helpful
    https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
    Use something like import subprocess subprocess.check_call(["python", '-m', 'pip', 'install', 'pkg']) # install pkg subprocess.check_call(["python", '-m', 'pip', 'install',"--upgrade", 'pkg']) # upgrade pkg


    Edit: pip 10.0.1 still doesn't support main
    You can choose to DOWNGRADE your pip version via following command:
    python -m pip install --upgrade pip==9.0.3

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

    Pip 10.0.* doesn't support main.

    You have to downgrade to pip 9.0.3.

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

    It works well:

     py -m pip install --user --upgrade pip==9.0.3
    
    0 讨论(0)
  • 2020-11-29 01:21

    Edit file: C:\Users\kpate\hw6\python-zulip-api\zulip_bots\setup.py in line 108

    to

    rcode = pip.main(['install', '-r', req_path, '--quiet'])
    

    do

    rcode = getattr(pip, '_main', pip.main)(['install', '-r', req_path, '--quiet'])´
    
    0 讨论(0)
  • 2020-11-29 01:22

    For me this issue occured when I was running python while within my site-packages folder. If I ran it anywhere else, it was no longer an issue.

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