在Ubuntu中使用python的pygal库无法创建svg文件
代码如下:
from die import Die
import pygal
die = Die()
results = []
for roll_num in range(1000):
result = die.roll()
results.append(result)
frequencies = []
for value in range(1,die.num_sides+1):
frequency =results.count(value)
frequencies.append(frequency)
hist = pygal.Bar()
hist.title = "Result of rolling one D6 1000 times"
hist.x_labels = ['1','2','3','4','5','6']
hist.y_title = "Frequency of Result"
hist.x_titlr = "Result"
hist.add('D6',frequencies)
hist.render_to_file('die_visual.svg')
返回的错误代码如下:
Traceback (most recent call last):
File "/home/dengguijiang/Public/test/die_visual.py", line 24, in <module>
hist.render_to_file('die_visual.svg')
File "/usr/local/lib/python3.5/dist-packages/pygal/ghost.py", line 165, in render_to_file
f.write(self.render(is_unicode=True, **kwargs))
File "/usr/local/lib/python3.5/dist-packages/pygal/ghost.py", line 122, in render
.make_instance(overrides=kwargs)
File "/usr/local/lib/python3.5/dist-packages/pygal/ghost.py", line 116, in make_instance
self.xml_filters)
File "/usr/local/lib/python3.5/dist-packages/pygal/graph/bar.py", line 37, in __init__
super(Bar, self).__init__(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pygal/graph/base.py", line 47, in __init__
self.svg = Svg(self)
File "/usr/local/lib/python3.5/dist-packages/pygal/svg.py", line 50, in __init__
u('xml'), u("version='1.0' encoding='utf-8'"))]
File "src/lxml/lxml.etree.pyx", line 3039, in lxml.etree.ProcessingInstruction (src/lxml/lxml.etree.c:77253)
ValueError: Invalid PI name 'b'xml''
请问这个问题怎么解决