error in import statement in reportlab
I needed help in understanding the root of the 开发者_高级运维following error. While running a bar chart generating code in reportlab from the url https://www.reportlab.com/snippets/3/ ,I am facing an error on line
from standard_colors import pdf_chart_colors, setItems
stating that:
Import Error: No module named standard_colors
I dont understand whether there is a problem while installing reportlab or some thg else. Please guide.
I got curious on this question and begin digging. There's a post stating what should be the standard_colors source code.
standard_colors.py:
from reportlab.lib.colors import HexColor
pdf_chart_colors = [ HexColor("#0000e5"), HexColor("#1f1feb"), HexColor("#5757f0"), HexColor("#8f8ff5"), HexColor("#c7c7fa"), HexColor("#f5c2c2"), HexColor("#eb8585"), HexColor("#e04747"), HexColor("#d60a0a"), HexColor("#cc0000"), HexColor("#ff0000"), ]
def setItems(n, obj, attr, values):
m = len(values)
i = m // n
for j in xrange(n):
setattr(obj[j],attr,values[j*i % m])
source: https://www.reportlab.com/snippets/3/
精彩评论