Search code examples
pythonpiptweepy

No module named pip.req


I am installing tweepy, but I am running into an error about pip.req. I have pip installed, but for some reason pip.req still can't be found. I did a bunch of research online and the most I could find was some issue about incompatibilities between zapo (?) and python 2.7 causing the same error for some other user. The discussion was unclear about how to solve the problem, though. Thanks!

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

Solution

  • It looks like it would work if you had this code:

    def parse_requirements(filename):
        """ load requirements from a pip requirements file """
        lineiter = (line.strip() for line in open(filename))
        return [line for line in lineiter if line and not line.startswith("#")]
    

    Do this:

    1. create a directory pip/
    2. add an empty file pip/__init__.py
    3. add a file pip/req.py
    4. put the code above into pip/req.py:
    5. modify the line in setup.py

      reqs = install_reqs