|
From: Ryan N. <rne...@gm...> - 2015-03-20 15:49:11
|
Thanks, Ben. I should have made that more clear. If I run the code from the
PR, I get the following error:
Traceback (most recent call last):
File "junk.py", line 11, in <module>
image = pyplot.imread(data) # crash on py3.x
File
"/home/nelson/apps/miniconda/lib/python3.4/site-packages/matplotlib/pyplot.py",
line 2215, in imread
return _imread(*args, **kwargs)
File
"/home/nelson/apps/miniconda/lib/python3.4/site-packages/matplotlib/image.py",
line 1270, in imread
return handler(fname)
RuntimeError: _image_module::readpng: file not recognized as a PNG file
My code that I'm trying to port essentially does the same thing, and I get
the same error. I ran this example just now from Anaconda Python 3.4
install with MPL 1.4.3.
My impression from the PR was that this should work out of the box now. I
figured that maybe that was not quite the case. The implementations between
Py2 and 3 are quite different. Figured there must be a different way that I
wasn't aware of.
Ryan
On Fri, Mar 20, 2015 at 9:51 AM, Benjamin Root <ben...@ou...> wrote:
> According to the PR you reference, the fix for this was merged back in Jan
> 2013, so that means that this fix is in version 1.2.x and up. Are you
> saying that you still can't do imread(urllib.request.urlopen(url))?
>
> On Thu, Mar 19, 2015 at 8:54 PM, Ryan Nelson <rne...@gm...>
> wrote:
>
>> Hello all,
>>
>> I'm porting over some code that used Py2.7 urllib2.urlopen(url) to grab
>> some image data from the net and load with pyplot.imread. It doesn't work
>> quite right in Py3.4. I found a couple of refs:
>>
>> https://github.com/matplotlib/matplotlib/pull/1650
>>
>> http://stackoverflow.com/questions/15183170/python-crash-when-downloading-image-as-numpy-array
>>
>> They suggest io.BytesIO(urllib.request.urlopen(url).read()) as a
>> replacement for Py3. Is this the best practice? Does anyone know a simpler
>> way to do this?
>>
>> Ryan
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website,
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub
>> for all
>> things parallel software development, from weekly thought leadership
>> blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
|