xlrd module problems

109 views
Skip to first unread message

Miguel Angel

unread,
Apr 4, 2012, 8:01:55 AM4/4/12
to pyins...@googlegroups.com
Hi all,
i have been using Pyinstaller to freeze a program in Windows for some time
now, i have just upgraded xlrd module (http://pypi.python.org/pypi/xlrd) and the
last version (0.7.6) have this line in __init__.py:

__VERSION__ = open(path.join(path.dirname(__file__), 'version.txt')).read().strip()

and the corresponding file in C:\Python27\Lib\site-packages\xlrd\version.txt
with "0.7.6" as the only content, now my program fails after freeze with this error:

Traceback (most recent call last):
File
"c:\gestion_financiera\build\pyi.win32\gestion_financiera\outPYZ1.pyz/mainwindow",
line 230, in on_action_Empresas_del_grupo_triggered
File "C:\pyinstaller-1.5\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\pyinstaller-1.5\iu.py", line 521, in doimport
exec co in mod.__dict__
File
"c:\gestion_financiera\build\pyi.win32\gestion_financiera\outPYZ1.pyz/empresa_grupo_widget",
line 6, in <module>
File "C:\pyinstaller-1.5\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\pyinstaller-1.5\iu.py", line 521, in doimport
exec co in mod.__dict__
File
"c:\gestion_financiera\build\pyi.win32\gestion_financiera\outPYZ1.pyz/xlrd",
line 5, in <module>
IOError
[Errno 2] No such file or directory:
'c:\\gestion_financiera\\build\\pyi.win32\\gestion_financiera\\outPYZ1.pyz\\version.txt'

I have collected datafiles before but i don't know how to collect a file and put
it inside the outPYZ1.pyz archive, and i am not sure that putting directly there
a file with a common name like "version.txt" would be a good idea anyway, i
suppose i should be doing anything else.

In the meantime i have changed the xlrd __init__.py to '__VERSION__ = "0.7.6"'
but don't seems to me like a good idea keep modifying modules sources to get my
application freeze correctly.

What should i do? Thanks.

Regards,
Miguel Angel.

Hartmut Goebel

unread,
Apr 5, 2012, 7:30:29 AM4/5/12
to pyins...@googlegroups.com
Am 04.04.2012 14:01, schrieb Miguel Angel:
> i have been using Pyinstaller to freeze a program in Windows for some time
> now, i have just upgraded xlrd module (http://pypi.python.org/pypi/xlrd) and the
> last version (0.7.6) have this line in __init__.py:
>
> __VERSION__ = open(path.join(path.dirname(__file__), 'version.txt')).read().strip()

This will simply not work with a frozen app. Please see the manual for
hot to adopt for being frozen.

> I have collected datafiles before but i don't know how to collect a file and put
> it inside the outPYZ1.pyz archive, and i am not sure that putting directly there
> a file with a common name like "version.txt" would be a good idea anyway, i
> suppose i should be doing anything else.

Even if you'd add the file to the PYZ, the line above will not work:
open() can not open content within an archive (no matter if PYZ or zip
or something else).

> What should i do? Thanks.

Best solution is to contact the author so he will change his code. (IMHO
Reading the version number from an external file is no good idea anyway.)

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult ist Mitglied bei http://www.7-it.de


Miguel Angel Rasero

unread,
Apr 6, 2012, 3:21:27 AM4/6/12
to pyins...@googlegroups.com
 Yeah, i think so, thanks Hartmut, i have notified xlrd developers in his mailing list.

Regards,
Miguel Angel.
Reply all
Reply to author
Forward
0 new messages