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条回答
Explosion°爆炸
2楼-- · 2020-01-27 14:48

It works well:

 py -m pip install --user --upgrade pip==9.0.3
查看更多
The star\"
3楼-- · 2020-01-27 14:51

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.

查看更多
Summer. ? 凉城
4楼-- · 2020-01-27 14:51

Pip 10.0.* doesn't support main.

You have to downgrade to pip 9.0.3.

查看更多
【Aperson】
5楼-- · 2020-01-27 14:52

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

查看更多
聊天终结者
6楼-- · 2020-01-27 14:52

Not sure about Windows. But for mac users, use this:

pip install --upgrade pip==9.0.3
查看更多
beautiful°
7楼-- · 2020-01-27 14:52

I fixed this problem upgrading to latest version

sudo pip install --upgrade pip

My version: pip 18.1 from /Library/Python/2.7/site-packages/pip (python 2.7)

查看更多
登录 后发表回答