AttributeError: Module Pip has no attribute 'main'

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

提交回复
热议问题