Pip: Manually specifying version 18.0 gives an error

Created on 5 Oct 2018  路  7Comments  路  Source: pypa/pip

Environment

  • pip version:
  • Python version: 3.6.6 and 3.7.0 tested
  • OS: Ubuntu 18.04

Description

the command "python get-pip.py pip==18.0"
gives a result of "Double requirement given: pip (already in pip==18.0, name='pip')"
Expected behavior

This worked fine a day ago, so I suspect a regression with the latest release.
How to Reproduce

sh> PIPVERSION=18.0
sh> curl -o /tmp/get-pip.py -sSL "https://bootstrap.pypa.io/get-pip.py"
sh> python /tmp/get-pip.py pip==${PIPVERSION}
sh> python --version

Output

build@997821efc658:/work$ PIPVERSION=18.0
build@997821efc658:/work$ curl -o /tmp/get-pip.py -sSL "https://bootstrap.pypa.io/get-pip.py"
build@997821efc658:/work$ python /tmp/get-pip.py pip==${PIPVERSION}
Double requirement given: pip (already in pip==18.0, name='pip')
build@997821efc658:/work$ python --version
Python 3.6.6
wrong project auto-locked

Most helpful comment

You could also use a constraint: python get-pip.py -c <(echo 'pip==18.0').

All 7 comments

Ah! pip victim of its own internal API changes...

--- get-pip.py.orig 2018-10-05 13:30:50.000000000 +0200
+++ get-pip.py  2018-10-05 17:36:01.236818917 +0200
@@ -81,7 +81,7 @@
     # Import pip so we can use it to install pip and maybe setuptools too
     import pip._internal
     from pip._internal.commands.install import InstallCommand
-    from pip._internal.req import InstallRequirement
+    from pip._internal.req.constructors import install_req_from_line

     # Wrapper to provide default certificate with the lowest priority
     class CertInstallCommand(InstallCommand):
@@ -134,7 +134,7 @@
     # install of them.
     for arg in args:
         try:
-            req = InstallRequirement.from_line(arg)
+            req = install_req_from_line(arg)
         except Exception:
             continue

Temp workaround:

sed -i -e '84s/from\ pip\._internal\.req\ import\ InstallRequirement/from\ pip\._internal\.req\.constructors\ import\ install_req_from_line/g' get-pip.py

sed -i -e '137s/req\ =\ InstallRequirement\.from_line(arg)/req\ =\ install_req_from_line(arg)/g' get-pip.py

based off the patch above.

You could also use a constraint: python get-pip.py -c <(echo 'pip==18.0').

Ah! pip victim of its own internal API changes...

--- get-pip.py.orig   2018-10-05 13:30:50.000000000 +0200
+++ get-pip.py    2018-10-05 17:36:01.236818917 +0200
@@ -81,7 +81,7 @@
     # Import pip so we can use it to install pip and maybe setuptools too
     import pip._internal
     from pip._internal.commands.install import InstallCommand
-    from pip._internal.req import InstallRequirement
+    from pip._internal.req.constructors import install_req_from_line

     # Wrapper to provide default certificate with the lowest priority
     class CertInstallCommand(InstallCommand):
@@ -134,7 +134,7 @@
     # install of them.
     for arg in args:
         try:
-            req = InstallRequirement.from_line(arg)
+            req = install_req_from_line(arg)
         except Exception:
             continue

If you've verified this fix works, would you mind submitting it as a PR?

Ah! pip victim of its own internal API changes...

Wheee.

Closing since the get-pip PR is merged.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings