AttributeError: Module Pip has no attribute 'm

2020-01-27 14:11发布

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 python3 and my pip version is 10.0.0. The file in question is setup.py and the code that is messing up is when the pip.main() attribute is accessed to install a package.

Now, I know this build should succeed because its an open source project, but I have been trying for hours to fix the dependency issue regarding pip.main().

Any help would be greatly appreciated.

enter image description here

标签: python pip
16条回答
叼着烟拽天下
2楼-- · 2020-01-27 14:33

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.

查看更多
孤傲高冷的网名
3楼-- · 2020-01-27 14:35

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.

查看更多
萌系小妹纸
4楼-- · 2020-01-27 14:35

Try this command.

python -m pip install --user pip==9.0.1
查看更多
Rolldiameter
5楼-- · 2020-01-27 14:36

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'])´
查看更多
贪生不怕死
6楼-- · 2020-01-27 14:39

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])
查看更多
做自己的国王
7楼-- · 2020-01-27 14:46

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

查看更多
登录 后发表回答