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 IT department gave the machine a corrupted version of pip. The recommended answers below probably would have worked but were blocked by the company's IT department and required admin login to do. I have since left that project and hope to avoid similar situations.
I'm attempting to install a WHL file
While attempting to run:
import pip
my_path = <a path to the WHL file>
pip.main(['install', my_path])
I received an Attribute error:
'module' object has no attribute 'main'
I ran help(pip) and
__main__
was listed as a package content.
I'm running Python 3.4 in the console.
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"])
easy_install --upgrade pip
worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With