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

pkg_resources.ContextualVersionConflict: urllib3, requests #229

Closed
brlin-tw opened this issue Apr 28, 2019 · 6 comments
Closed

pkg_resources.ContextualVersionConflict: urllib3, requests #229

brlin-tw opened this issue Apr 28, 2019 · 6 comments

Comments

@brlin-tw
Copy link
Contributor

brlin-tw commented Apr 28, 2019

The edge channel snap crashes when launching with the following message:

$ gallery-dl
Traceback (most recent call last):
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (urllib3 1.25.1 (/snap/gallery-dl/x2/lib/python3.6/site-packages), Requirement.parse('urllib3<1.25,>=1.21.1'), {'requests'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/gallery-dl/x2/bin/gallery-dl", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/snap/gallery-dl/x2/lib/python3.6/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (urllib3 1.25.1 (/snap/gallery-dl/x2/lib/python3.6/site-packages), Requirement.parse('urllib3<1.25,>=1.21.1'), {'requests'})

I suspect the c35217e commit causes this error, can you check it out?
I'll implement a CI test to catch this kind of runtime error more promptly.

@Hrxn
Copy link
Contributor

Hrxn commented Apr 28, 2019

I think it's because the latest urllib3 version 1.25.1 (as indicated in your log) is not working with requests at the moment. They haven't updated it yet. But an attempt is, uh, underway.

https://github.com/kennethreitz/requests/issues/5067
https://github.com/kennethreitz/requests/pull/5063

brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to brlin-tw/gallery-dl that referenced this issue Apr 28, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue mikf#229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
mikf added a commit that referenced this issue Apr 29, 2019
Wouldn't be necessary if pip would do proper version management.
As things are right now, pip ignores the urllib3 version requirements
from requests because gallery-dl is specifying its own.
@mikf
Copy link
Owner

mikf commented Apr 29, 2019

Setting a maximum version for urllib3 (and requests) fixed it. Would be nice if pip could respect gallery-dl's and request's version requirements at the same time.

Also: why does a Python snap do version checks at run-time, but not during build-time? (rhetorical question)

@iamleot
Copy link
Contributor

iamleot commented Apr 29, 2019 via email

@mikf
Copy link
Owner

mikf commented Apr 29, 2019

urllib3 1.24.1 & 1.24.2 cause some issues with artstation (#227) and when bypassing some Cloudflare challenge pages, but with 1.24 and the new 1.25.x it works ... for whatever reason. I already looked at the diff between 1.24 and 1.24.1 and there is really nothing that should cause these issues, but they happen nonetheless.

[mike tmp ]$ python -m pip install --user urllib3==1.24.1
...
Successfully installed urllib3-1.24.1
[mike tmp ]$ gallery-dl https://www.artstation.com/nshade
[artstation][error] HTTP request failed:  403: Forbidden for url: https://www.artstation.com/users/nshade/quick.json

[mike tmp ]$ python -m pip install --user urllib3==1.24
...
Successfully installed urllib3-1.24
[mike tmp ]$ gallery-dl https://www.artstation.com/nshade
/tmp/artstation/nshade/artstation_3365702_11700926_Lightforged Draenei.jpg
^C
KeyboardInterrupt

So I added some version specification to setup,py and requirements.txt to exclude those faulty versions (c35217e), but that causes pip to ignore the version specification from requests ("urllib3 < 1.25"), and this in turn installs and uses urllib3 1.25.x when building the gallery-dl snap, which brings us to this here issue.

I'm going to wait until requests supports the new urllib3 version and remove those version specs before releasing the next version of gallery-dl , but until then - to keep the Snap from breaking - I'll keep it this way.

mikf pushed a commit that referenced this issue Apr 30, 2019
This ensure snap build-time and run-time problems will be noticed more
promptly by the maintainers, like issue #229.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
mikf added a commit that referenced this issue May 3, 2019
Cloudflare now also checks the client's SSL/TLS cipher capabilities and
produces a 403: Forbidden response with CAPTCHA if they are insufficient.

This commit replaces the default cipher list in urllib3 < 1.25 with the
one from 1.25 (1), which doesn't cause problems as long as the client
platform actually supports these ciphers. On some platforms (tested with
Python 3.4 on Linux and Python 3.7 on an outdated Windows 7 VM) it is
necessary to install pyOpenSSL to get everything to work.

Explicitly setting a minimum/maximum version for urllib3 is also no
longer necessary and installing gallery-dl will therefore not pull a
incompatible urllib3 version (#229)

Fixes the "403: Forbidden" error on Artstation (#227)

(1) urllib3/urllib3@0cedb3b
@mikf
Copy link
Owner

mikf commented May 3, 2019

I've managed to figure out why urllib3 1.24.1 and 1.24.2 (as well as older versions) caused some issues and built a workaround for it (35f3432).

Version requirements for urllib3 have been removed and incompatibilities between requests and urllib3 in Snaps should no longer happen.

@mikf mikf closed this as completed May 3, 2019
@iamleot
Copy link
Contributor

iamleot commented May 3, 2019 via email

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

No branches or pull requests

4 participants