Inline plots do not seem to be working in my current configuration. Maybe a version thing?
Python 3.2.3
matplotlib 1.2.0
IPython 0.13.1
PTVS 1.5
From: Dino
It looks like IPython is giving is a string which is failing to decode. If you open visualstudio_ipython_repl.py (it’s where PTVS is installed) and modify write_data to add the 2 green lines:
def write_data(self, data, execution_count = None):
output_png = data.get('image/png', None)
if output_png is not None:
try:
if isinstance(output_png, str) and sys.version_info[0] >= 3:
output_png = output_png.encode('utf8')
self._vs_backend.write_png(decodestring(output_png))
self._vs_backend.write_stdout('\n')
Then it should work.
It seems odd to me that they’re giving us a string, and I can’t be certain that utf8 is the right encoding, but it appears to be working. I’ll ping the IPython devs and see if that’s right or what’s going on here.
Additional Fix:
Thanks for the quick fix Dino. It made my demo just now a lot prettier.
There’s one other py3 related change I needed to make:
def execute_file_as_main(self, filename):
f = open(filename, 'rb')
try:
contents = f.read().replace(b"\r\n", b"\n")
finally:
f.close()
code = '''