我正在编写一些计算和显示大量SVG数据的IPython / Jupyter笔记本。作为一个最小的例子,请考虑以下内容:
几乎每次我重新打开这样的笔记本(尤其是大笔记本)时,他们的数字都会被文字输出取代:
当然,我可以通过运行所有细胞来重新计算它们。但它很长,而且数据实际上存在于JSON {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"300\" xmlns=\"http://www.w3.org/2000/svg\">\n",
"\n",
" <rect fill=\"red\" height=\"100%\" width=\"100%\"/>\n",
"\n",
" <circle cx=\"150\" cy=\"100\" fill=\"green\" r=\"80\"/>\n",
"\n",
" <text fill=\"white\" font-size=\"60\" text-anchor=\"middle\" x=\"150\" y=\"125\">SVG</text>\n",
"\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.core.display import SVG\n",
"SVG(url=\"https://mdn.mozillademos.org/files/3075/svgdemo1.xml\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
文件中:
{prefix}-{id}-{postfix}
我做错了吗?这是一个已知的错误?你能在the same notebook上重现这种行为吗?如何确保每次重新打开笔记本时都能正确显示SVG输出?
配置:全新的Mac OS X 10.10.4安装最新的IPython Notebook Anaconda软件包,但没有任何后续手动更新(即,这仍然是IPython 3.2.0-py27_0)。