Skip to content Skip to sidebar Skip to footer

Pip Module Has No Attribute "main"

EDIT: The computer in question was a client machine with restrictions on what software could be installed. I'm unsure if that may have been a cause of the issue or if the client's

Solution 1:

they made a refactoring. you can support both 9 and 10 pip by using:

try:
    from pip import main as pipmain
except:
    from pip._internal.main import main as pipmain

and then use pipmain as you used pip.main. for example

pipmain(['install', "--upgrade", "pip"])
pipmain(['install', "-q", "package"])

Solution 2:

easy_install --upgrade pip worked for me.

Solution 3:

My issue was related to my IDE (PyCharm). older versions of PyCharm does not support pip v10. Upgrading PyCharm solved it for me.

Solution 4:

For more recent versions of pip (pip>=10.0.0), the functionality described in the other answers will no longer work. I recommend running the pip with subprocess as follows:

import subprocess
import sys

my_path = <a path to the WHL file>
command_list = [sys.executable, "-m", "pip", "install", my_path]
with subprocess.Popen(command_list, stdout=subprocess.PIPE) as proc:
    print(proc.stdout.read())

This solution uses the current python executable to run the pip command as a commandline command. It was inspired by the solution mentioned here.

Solution 5:

From pip 20.0.0, it's:

from pip._internal.cli.main import main as pipmain

Post a Comment for "Pip Module Has No Attribute "main""