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

IPython qtconsole (0.12) can't export to html with external png #1164

Closed
claumann opened this issue Dec 16, 2011 · 5 comments · Fixed by #1165
Closed

IPython qtconsole (0.12) can't export to html with external png #1164

claumann opened this issue Dec 16, 2011 · 5 comments · Fixed by #1165
Milestone

Comments

@claumann
Copy link
Contributor

This error looks a bit like that in issue #1087 but the details are different. I create a qtconsole session with some embedded figures. Export to HTML with inline PNG works fine. Export to XHTML/SVG 'works' (with missing images). Export to HTML with external PNG creates a folder with the PNG files correctly but fails to write the HTML (leaving a zero size .html file) with the following error:

Error exporting HTML to /Users/claumann/Desktop/test/test.html
'ascii' codec can't decode byte 0xc2 in position 2287: ordinal not in range(128)

I have an html (with embedded PNG) that constitutes a minimal session reproducing this but I don't know how to attach it to this issue. The (non-graphical) content:

In [1]: figure()
scatter(r_[0,1,2], r_[0,1,2], marker='x')
display(gcf())

<embedded image>

In [2]: !uname -a
Darwin blackbear.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64

In [3]: np.__version__
Out[3]: '2.0.0.dev-26aa3cf'

In [4]: pylab.__version__
Out[4]: '2.0.0.dev-26aa3cf'

In [5]: matplotlib.__version__
Out[5]: '1.2.x'
@fperez
Copy link
Member

fperez commented Dec 16, 2011

I can confirm the problem, and it's truly weird: if I type this:

scatter(r_[0,1,2], r_[0,1,2], marker='x')

everything seems to work fine. But if instead I do this:

figure()
scatter(r_[0,1,2], r_[0,1,2], marker='x')

then saving with external PNG produces the error you indicate above. Now, those two calls should be the same from our perspective, so I really don't get what's going on. We'll have to dig in to figure this out, but obviously we can't release 0.12 with broken qt console export.

Thanks for the timely report!

@minrk
Copy link
Member

minrk commented Dec 16, 2011

simple reproduce:

In [1]: u'é'
In [2]: plot(rand(100))
<save>

I've narrowed it down to image_tag returning unicode, but re.sub not handling that properly. Ensuring that image_tag returns utf8-encoded str solves the issue, and I'm right now just trying to figure out the best way to do it.

@fperez
Copy link
Member

fperez commented Dec 16, 2011

Actually, I just confirmed that this bug exists since 0.11, so I'm bringing the priority down to high. If the bug has been in the wild for 4 months, I don't want to hold the 0.12 release just for it.

But still, it is real and serious, so we should definitely try to address it ASAP. With a bit of luck we'll have it fixed before the release, but since that's coming this weekend, it may not quite happen right away.

@fperez
Copy link
Member

fperez commented Dec 16, 2011

Ah, yes: the re library is known to have unicode issues, there's even a proposed new regexp library for python itself partly due to these problems. Thanks for getting onto this one!

@minrk
Copy link
Member

minrk commented Dec 16, 2011

PR #1165 seems to address the issue

@fperez fperez closed this as completed in 376addf Dec 16, 2011
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
encode image_tag as utf8 in [x]html export

Should only affect Python 2
    
Also removes redundant 'setDefaultButton' in Inline/External dialog, which caused strange display of the two buttons.

closes ipython#1164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants