Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Import error provides wrong message #58

@mlissner

Description

@mlissner

The code here isn't always accurate:

https://github.com/googleapis/google-resumable-media-python/blob/master/google/resumable_media/requests/__init__.py#L664-L673

Basically, it says that a certain version of requests is required, but the ResolutionError that's caught can be thrown by other reasons. In my case, I satisfied the requirement for requests, but I had a version conflict in a different module. As pointed out by pipdeptree (a tool that makes a tree of your pip dependencies):

Warning!!! Possibly conflicting dependencies found:
* requests==2.20.0
 - idna [required: >=2.5,<2.8, installed: 2.8]

And when I tried to run the pkg_resources.require('requests >= 2.18.0') code myself, I got this error:

In [2]: pkg_resources.require('requests >= 2.18.0')
---------------------------------------------------------------------------
ContextualVersionConflict                 Traceback (most recent call last)
<ipython-input-2-615e205ac6e7> in <module>()
----> 1 pkg_resources.require('requests >= 2.18.0')

/var/www/.virtualenvs/courtlistener/local/lib/python2.7/site-packages/pkg_resources/__init__.pyc in require(self, *requirements)
    896         included, even if they were already activated in this working set.
    897         """
--> 898         needed = self.resolve(parse_requirements(requirements))
    899 
    900         for dist in needed:

/var/www/.virtualenvs/courtlistener/local/lib/python2.7/site-packages/pkg_resources/__init__.pyc in resolve(self, requirements, env, installer, replace_conflicting, extras)
    787                 # Oops, the "best" so far conflicts with a dependency
    788                 dependent_req = required_by[req]
--> 789                 raise VersionConflict(dist, req).with_context(dependent_req)
    790 
    791             # push the new requirements onto the stack

ContextualVersionConflict: (idna 2.8 (/var/www/.virtualenvs/courtlistener/lib/python2.7/site-packages), Requirement.parse('idna<2.8,>=2.5'), set(['requests']))

The error message here should be removed and if possible replaced with the message that's thrown by pkg_resources.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions