error when trying to import image in pod

Asked by Wesley St.Clair on 2011-09-14

I am still not having luck importing an image using pod. The "note" in my temp.odt file looks like:

do text
from document(at='logo.png')

The Python code I execute is:

from appy.pod.renderer import Renderer
rendered = Renderer('temp.odt', {}, 'res.odt')

This creates res.odt, but with the following error in the note field:

Error while evaluating the expression "document(at='logo.png')" defined in the "from" part of a statement.
File "<string>", line 1, in <module>
File "c:\python27\lib\site-packages\appy\pod\", line 293, in importDocument
res =
File "c:\python27\lib\site-packages\appy\pod\", line 224, in run
width, height = getSize(self.importPath, self.format)
File "c:\python27\lib\site-packages\appy\pod\", line 190, in getSize
return float(x)/pxToCm, float(y)/pxToCm
<type 'exceptions.TypeError'>: float() argument must be a string or a number

It looks like importPath is getting set incorrectly. I am developing on Windows. I do not see a way to attach files to this ticket, but I can send the .odt and .py I am working with if that helps. Thanks!

Question information

English Edit question
Appy Edit question
No assignee Edit question
Solved by:
Wesley St.Clair
Last query:
Last reply:

Indeed, this bug was detected by another Windows user, I dont't find the related bug or question, but try this:
At the beginning of method "getSize" in, write

f = file(filePath, 'rb')

instead of

f = file(filePath, 'r')

Does it work ?

This bugfix is still unpublished, only committed in the trunk. Appy 0.7.0 will arive soon with this shipped.
Sorry for the inconveniences !

Wesley St.Clair (wes-stclair) said : #2

It is closer, but I am still having difficulty, and I have a feeling that it is still related to Windows. Now, when I, my output .odt file is created and the placeholder is there for the image, but the image is not actually showing. If I right-click where the image should be and go into "picture", it tells me the file name is "file:///C:/Documents and Settings/Wes/Desktop/result.odt/C:\Documents and Settings\Wes\Desktop\result.odt.1316829798.535000\unzip\Pictures\logo.jpg". As you can see, I am working off of my desktop, but this file path is not a valid file path... at least I don't think it is. Do you have any further suggestions? Thanks!

Wesley St.Clair (wes-stclair) said : #4

Works perfect, thanks!