AttributeError: Module Pip has no attribute ‘main’

Each Answer to this Q is separated by one/two green lines.

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 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

python3 -m pip install --user --upgrade pip==9.0.3

pip issue: rollback

It appears that pip did a refactor and moved main to internal. There is a comprehensive discussion about it here:

A workaround for me was to change

import pip


from pip._internal import main

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

First run

import pip

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

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

This helps me,

curl -o

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


It works for me.

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
    from pip import main
def install(package):
    main(['install', package])

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.

If python -m pip install --upgrade pip==9.0.3 doesn’t work, and you’re using Windows,

  1. Navigate to this directory and move the pip folders elsewhere.

enter image description here

  1. Close your IDE if you have it open.

  2. Press ‘Repair’ on Python 3.

enter image description here

  1. Your IDE should cease to detect pip packages and prompt you to install them. Install and keep the last stable pip version by blocking automatic updates.
    enter image description here

Pip 10.0.* doesn’t support main.

You have to downgrade to pip 9.0.3.

Try this command.

python -m pip install --user pip==9.0.1

It works well:

 py -m pip install --user --upgrade pip==9.0.3

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


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


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

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

pip install --upgrade pip==9.0.3

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)

I faced the same error while using pip on anaconda3 4.4.0 (python 3.6) on windows.

I fixed the problem by the following command:

easy_install pip==18.*  ### installing the latest version pip

Or if lower version pip required, mention the same in the command.

Or you can try installing the lower version and then upgrading the same to latest version as follow:

easy_install pip==9.0.1

easy_install --upgrade pip

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.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .