Install pip module: ImportError: No module named pip.req

  • A+
Category:Languages
  1. Installation of pip using get-pip.py is breaking. it saysRequirement already up-to-date: pip in /tmp/tmpvF6RoH/pip.zip (10.0.0)
  2. No module named pip.req

while installing a pip module


Traceback (most recent call last):
File "setup.py", line 5, in <module>
from pip.req import parse_requirements
ImportError: No module named pip.req

 


Installation

For installation using get-pip.py use the --force-reinstall flag:

$ python get-pip.py --force-reinstall 

Obviously this is till they fix the problem https://github.com/pypa/pip/issues/5220


Imports from pip

If you have any imports from pip, such as:


try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements

Important

Now that said it's not a good practice to use the internal pip functions, due to multiple reasons as mentioned here: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: