-
Notifications
You must be signed in to change notification settings - Fork 3k
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 9.0.2 KeyError: 'pip._vendor.urllib3.contrib' #5079
Comments
I'm seeing the same thing with pip 9.0.2 while running on the
I've been able to narrow it down to occurring when the
The reverse works fine:
|
Are you importing pip in your code? Or is there a pip command you're running to trigger this? |
In my case, I'm importing pip in my code to use |
Does it happen on the |
(If you're using |
Was just checking that. It looks like
|
(good to know about the |
You'll need to |
Ah, yep. Seeing that now. Still seems to work:
|
Alright. I'm inclined to say that that you'll want to either re-arrange your imports, or pin to This is largely because 9.0.x has drifted enough that cutting 9.0.2 was an ~8 hour process, and I'd much rather not have to do that again, particularly for an unsupported use of pip. If one of the other pip developers feel strongly about it, they're welcome to do it though. Sorry again! |
Yep, I can do that to solve my case. 👍 Understandable that it's not officially supported, but there's definitely usage of it out there. GitHub code search won't allow for using https://github.com/search?l=Python&q=import+pip+main%28&type=Code&utf8=%E2%9C%93 but it returns ~850k hits of An anecdotal pattern I notice from a quick look through them, is that many are installing data packages. Not surprising since there are many data environments (notebook deployments especially) that obfuscate access to the host environment. This is serving as an in-python way of managing dependencies that can be shared in such contexts. I'm not sure if there's any interest in maintaining the Just a thought though, I've already refactored to resolve my issue. |
I think this would make an excellent issue to discuss the relative merits of doing that (or not doing it). |
FWIW I'm seeing something very similar just by calling
Strangely, I can avoid the error by calling |
Importing pip 9.0.2 from the tests causes a crazy build failure. Apparently importing pip the way we do has never been supported and we should stop doing it. However, this stops the bleeding until we can figure out what to do correctly. Alternately, it's possible that when pip 10 comes out, the problem will go away by itself and we can continue doing the unsupported thing that we were doing. See also pypa/pip#5079 (comment).
Alright, well I was able to fix my problem by deleting the system pip cache. Now my jobs run as they were before, without needing to pin pip to 9.0.1 or specifying Dunno if this is related at all to what people are seeing here or on #5081, but noting my experience here nonetheless in case it helps someone. |
Pip does a bunch of magic vendoring of packages for its internal use. In pip 9.0.2, the logic of this changed in a way such that it is sometimes necessary for pip to be imported *before* anything else. There are some details on this in this thread: pypa/pip#5079 Ultimately, we will want to stop importing pip in our code. This is just a temporary fix so that things work in the short term.
- policy-handler uses dns based discovery of deployment-handler - driven by config - new data structure for deploy_handler section of config -- changed from string "deployment_handler" in 2.3.1 to structure in 2.4.0 deploy_handler : # name of deployment-handler service # used by policy-handler for logging target_entity : "deployment_handler" # url of the deployment-handler service # for policy-handler to direct the policy-updates to # - expecting dns to resolve the name # deployment_handler to ip address url : "http://deployment_handler:8188" - logic is backwards compatible with 2.3.1 format - removed import pip from audit -- import pip broken in pip 9.0.2 (2018-03-19) -- import pip conflicts with requests -- pip API is not officially supported -- see links for more pypa/pip#5079 pypa/pip#5081 Change-Id: Ifcaba6cfd714f3099ab7a25fe979a3696a6460fc Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-404
👍 I experience the problem inside the build of docker containers based on python:2.7-slim, python:3.5-slim etc. So I cannot do finegrained control of |
Currently there is a reported problem in pip library [1]. To avoid this problem, the pip version should be enforced during the installation. [1]pypa/pip#5079 JIRA: YARDSTICK-1087 Change-Id: I2ee28749f146cd3b0e1bf4ed92b51cbe6db8b2f3 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
* Update docs/submodules/yardstick from branch 'master' - Merge "Enforce pip version during installation" - Enforce pip version during installation Currently there is a reported problem in pip library [1]. To avoid this problem, the pip version should be enforced during the installation. [1]pypa/pip#5079 JIRA: YARDSTICK-1087 Change-Id: I2ee28749f146cd3b0e1bf4ed92b51cbe6db8b2f3 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Previously, we used internal pip code, which was changing in point releases, causing issues. We actually don't need pip to do this, we can instead ask the installed python's pkg_resources directly for the same info. Related issues: pypa/pip#5079 pypa/pip#5080 pypa/pip#5081
* Update docs/submodules/yardstick from branch 'master' - Merge "Re enable pip package unit tests" - Re enable pip package unit tests In [1] the pip unit test cases were removed, because of a problem in pip3 library. Currently there is a reported error in pip 9.0.2 version, in _vendor.urllib3 library [2]. This error is solved in [3]. [1]I43b1edc23cebe0db97b6b56a551acd376986dfea [2]pypa/pip#5079 [3]I2ee28749f146cd3b0e1bf4ed92b51cbe6db8b2f3 JIRA: YARDSTICK-1087 Change-Id: Id4f0e1accf3240b5f27d3698323e679a27f63f87 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
In [1] the pip unit test cases were removed, because of a problem in pip3 library. Currently there is a reported error in pip 9.0.2 version, in _vendor.urllib3 library [2]. This error is solved in [3]. [1]I43b1edc23cebe0db97b6b56a551acd376986dfea [2]pypa/pip#5079 [3]I2ee28749f146cd3b0e1bf4ed92b51cbe6db8b2f3 JIRA: YARDSTICK-1087 Change-Id: Id4f0e1accf3240b5f27d3698323e679a27f63f87 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
How to do it in windows?? |
This is a workaround for `pip` 9.0.2, which is the version that runs on Heroku. For some reason, importing `isort` import imports `requests`, and if we import `requests` before/without importing `pip`, we get a `KeyError`. We only need for this import to succeed locally and on CI (basically, anywhere where we want to run our test suite), so it's ok for this to fail on production. For more info: pypa/pip#5079 (comment)
* Gracefully ignore KeyError on isort import This is a workaround for `pip` 9.0.2, which is the version that runs on Heroku. For some reason, importing `isort` import imports `requests`, and if we import `requests` before/without importing `pip`, we get a `KeyError`. We only need for this import to succeed locally and on CI (basically, anywhere where we want to run our test suite), so it's ok for this to fail on production. For more info: pypa/pip#5079 (comment) * Bump version number
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. |
The text was updated successfully, but these errors were encountered: