Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip install: ImportError: No module named 'pip.req' #96

Closed
strk opened this issue Apr 4, 2018 · 4 comments · May be fixed by nash-io/neo-ico-template#32
Closed

pip install: ImportError: No module named 'pip.req' #96

strk opened this issue Apr 4, 2018 · 4 comments · May be fixed by nash-io/neo-ico-template#32

Comments

@strk
Copy link

strk commented Apr 4, 2018

~$ pip --version
pip 10.0.0b2 from /usr/local/lib/python3.4/dist-packages/pip-10.0.0b2-py3.4.egg/pip (python 3.4)
~$ pip install --user warrant-ext
Collecting warrant-ext
  Using cached warrant-ext-0.2.0.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-i1hxw5f7/warrant-ext/setup.py", line 4, in <module>
        from pip.req import parse_requirements
    ImportError: No module named 'pip.req'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-i1hxw5f7/warrant-ext/
@strk
Copy link
Author

strk commented Apr 4, 2018

pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4) successfully installs warrant-ext so I guess this issue should go to pip, not here...

@OliverHofkens
Copy link

This is not pip's fault. The official docs warn against using pip's internals, such as pip.req in this case. Version 10 of pip was just released and broke most code using their internal APIs, as announced here: Announcement: Pip 10 is coming, and will move all internal APIs.

One solution would be to manually list the requirements in setup.py instead of parsing them from requirements.txt. Another solution would be to use the packaging package and their Requirements API: https://packaging.pypa.io/en/latest/requirements/

@OliverHofkens
Copy link

A more direct fix would be this simple function to replace the pip.req.parse_requirements():

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("#")]

@bjinwright
Copy link
Member

This is fixed in develop and will be in v0.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants