Closed virtualbrown closed 7 years ago
Damn. Have you tried a second and third time just to be sure it wasn't a connexion problem (the error looks like a more serious issue but we never know).
@almarklein, any idea ?
Also can you give your Python version ?
The Dataset fetching aborted (__init__() got an unexpected keyword argument 'context')
is surprising, because it seems to originate from elsewhere (urllib?)
Below is the full trace.
It seems to be bombing out in
File "/usr/local/lib/python2.7/site-packages/imageio/core/fetching.py" in _fetch_file
I've tried this several times with no luck. Also I manually downloaded the requested file and that works fine.
Any chance there is a workaround here where I can manually install freeimage? :)
Thx!
Request Method: GET Request URL: http://127.0.0.1:8000/
Django Version: 1.7 Python Version: 2.7.9 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'rest_framework', 'home', 'user', 'api', 'utils', 'contactus', 'common', 'stream') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback: File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
Exception Type: IOError at / Exception Value: Error while fetching file https://github.com/imageio/imageio-binaries/raw/master/freeimage/libfreeimage-3.16.0-osx10.6.dylib. Dataset fetching aborted (init() got an unexpected keyword argument 'context')
Interesting. That last line in fetching.py actually catches an error and reraises it. I would very much like to know the original source. Can you try commenting the lines in imageio/core/fetching.py where the catching is done (in _fetch_file
)? Or maybe find out the real source via debugging?
Sorry just now getting back to this. I traced this down in to urllb2.py.
class HTTPHandler(AbstractHTTPHandler):
def http_open(self, req):
return self.do_open(httplib.HTTPConnection, req)
http_request = AbstractHTTPHandler.do_request_
if hasattr(httplib, 'HTTPS'): class HTTPSHandler(AbstractHTTPHandler):
def __init__(self, debuglevel=0, context=None):
AbstractHTTPHandler.__init__(self, debuglevel)
self._context = context
def https_open(self, req):
return self.do_open(httplib.HTTPSConnection, req,
context=self._context) <---- this is failing. _context is None. See do_open below.
def do_open(self, http_class, req, **http_conn_args): """Return an addinfourl object for the request, using http_class.
http_class must implement the HTTPConnection API from httplib.
The addinfourl return value is a file-like object. It also
has methods and attributes including:
- info(): return a mimetools.Message object for the headers
- geturl(): return the original request URL
- code: HTTP status code
"""
host = req.get_host()
if not host:
raise URLError('no host given')
# will parse host:port
h = http_class(host, timeout=req.timeout, **http_conn_args) <--- this is where the exception is thrown.
**http_conn_args is a dictionary containing
{'context': None}
LMK if you need more. I'm not familiar enough with urllib to really understand what is going on there.
From a brief look, I think this may be related to certificates. Can you please try changing https://
into http://
(i.e. remove the "s") in:
_url_root = 'https://github.com/imageio/imageio-binaries/raw/master/'
in fetching.py (line 47 in master).
Hi.
I made the change but still get the same error.
Exception Type: IOError at / Exception Value: Error while fetching file http://github.com/imageio/imageio-binaries/raw/master/freeimage/libfreeimage-3.16.0-osx10.6.dylib. Dataset fetching aborted (init() got an unexpected keyword argument 'context')
I made the following change in urllib2.py line 1166 and it worked. At least this got the library to install.
def do_open(self, http_class, req, **http_conn_args): """Return an addinfourl object for the request, using http_class.
http_class must implement the HTTPConnection API from httplib.
The addinfourl return value is a file-like object. It also
has methods and attributes including:
- info(): return a mimetools.Message object for the headers
- geturl(): return the original request URL
- code: HTTP status code
"""
host = req.get_host()
if not host:
raise URLError('no host given')
# will parse host:port
#h = http_class(host, timeout=req.timeout, **http_conn_args) <--- commented this out.
h = http_class(host, timeout=req.timeout)
Changing your urllib2.py file is not a very nice solution; it might break other code. Are you sure the http
thing did not work? Because if you look at the code for http_open
vs https_open
you see the http
version omits the context argument, which seems to be triggering the problem.
To be absolutely sure could you try just calling:
path = 'imageio/imageio-binaries/raw/master/freeimage/libfreeimage-3.16.0-osx10.6.dylib'
urlopen('https://github.com/' + path) # should fail
urlopen('http://github.com/' + path) # I hope this works
I tried that code and the http call fails as well with the following error.
init() got an unexpected keyword argument 'context' (<type 'exceptions.TypeError'>)
I'm pretty new to Python is it possible that I have incompatible libraries (based on version) somehow?
Also, regarding my tweak of urllib2, after I was able to download the file...I changed it back. I just needed a way to get around the download.
I am not sure about the cause. It seems rather specific to your system. I was hoping we could find a way to change imageio to avoid the error, but it seems this is not possible.
I am glad you solved your problem. Let's hope your case was a rare exception.
I'm leaving the issue open just in case someone else has the same problem.
I'm closing this issue as it sounds like OP solved their problem and 2+ years later, no-one else has commented to have run into the same problem.
Installed Moviepy on Mac. Try to run the first time and the download of free image is failing.
Exception Type: IOError at / Exception Value: Error while fetching file https://github.com/imageio/imageio-binaries/raw/master/freeimage/libfreeimage-3.16.0-osx10.6.dylib. Dataset fetching aborted (init() got an unexpected keyword argument 'context')