Tom Neill
Tom Neill

Reputation: 51

Unknown error in python pptx module add_picture

I've been trying to input a series of pictures onto every slide on a powerpoint presentation. I type in the image path, and the relevant dimensions, but I get an error which I don't understand.

    for k in xrange(0, len(prs.slides)):
        img_path = os_path + str(k+1) + '.png'
        left = Cm(1.21)
        top = Cm(4.72)
        width = Cm(5)
        height = Cm(5)
        pic = prs.slides[k].shapes.add_picture(img_path, left, top, width, height)

This error then appears:

  File "src/lxml/parser.pxi", line 1819, in lxml.etree._parseMemoryDocument (src\lxml\lxml.etree.c:116494)
  File "src/lxml/parser.pxi", line 1700, in lxml.etree._parseDoc (src\lxml\lxml.etree.c:115040)
  File "src/lxml/parser.pxi", line 1040, in lxml.etree._BaseParser._parseUnicodeDoc (src\lxml\lxml.etree.c:109165)
  File "src/lxml/parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:103404)
  File "src/lxml/parser.pxi", line 683, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:105058)
  File "src/lxml/parser.pxi", line 613, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:103967)
  lxml.etree.XMLSyntaxError: EntityRef: expecting ';', line 3, column 31

There is definitely a file that corresponds to the img_path, so I'm not sure what else is wrong

Upvotes: 1

Views: 531

Answers (1)

Tom Neill
Tom Neill

Reputation: 51

I think I fixed this.

My img_path in my documents included an & in the file name - I changed where the image was located (to a folder without an &) and it worked.

Upvotes: 1

Related Questions