Errors trying to include 'data' files

1,413 views
Skip to first unread message

Peter

unread,
Mar 29, 2010, 5:15:57 PM3/29/10
to PyInstaller
I've written what amounts to a GUI front end for mkisofs.exe using
wxpython. When I try to compile it with pyinstaller on Windows,
referencing just my script in the spec file, it works fine. Of
course, all the paths are hard coded to files such as mkisofs.exe that
are already on disk. Now I want to take the next step and include
those files in the single file output from pyinstaller. I don't
quite understand the manual's instructions on how to include other
files by treating them as data files, but I tried adding this to my
spec file:
collect = COLLECT([('mkisofs.exe','c:/fdu-build/mkisofs.exe','DATA')])

But when I run Build.py, it fails in building the TOC, saying
"building COLLECT outCOLLECT4.toc
Traceback (most recent call last):
(bunch of traceback statements)
File "C:\Pyhon25\lib\os.py", line 171 in makedirs
makedir(name, mode)
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'C:\\fdu-build\dist_C:'"

So, then I tried the approach suggested at
http://www.mail-archive.com/pyins...@googlegroups.com/msg01210.html,
adding
'a.data += [('c:\\fdu-build\mkisofs.exe','DATA','/temp/mkisofs.exe')]'
to the spec file. But that produces this error:
'AttributeError: Analysis instance has no attribute 'data'.

Here's my complete spec file including the a.data attempt:
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
os.path.join(HOMEPATH,'support\\useUnicode.py'), 'makeisogui.py'],
pathex=['C:\\fdu-build'])
a.data += [('/fdu-build/mkisofs.exe','DATA','/temp/mkisofs.exe')]
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'makeisogui.exe'),
debug=False,
strip=False,
upx=True,
console=True )


Eventually, I'll need to add about ten other (static) files, but for
now I'm just trying to make it work with one. I've tried it with
drive letters, without, etc., but can't figure out what I'm doing
wrong. Any ideas? Thanks.

Peter

Giovanni Bajo

unread,
Mar 29, 2010, 5:36:19 PM3/29/10
to pyins...@googlegroups.com
On Mon, 2010-03-29 at 14:15 -0700, Peter wrote:

> So, then I tried the approach suggested at
> http://www.mail-archive.com/pyins...@googlegroups.com/msg01210.html,
> adding
> 'a.data += [('c:\\fdu-build\mkisofs.exe','DATA','/temp/mkisofs.exe')]'
> to the spec file. But that produces this error:
> 'AttributeError: Analysis instance has no attribute 'data'.

Typo here, you should try with "datas" instead of data, as seen here:

> # -*- mode: python -*-
> a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
> os.path.join(HOMEPATH,'support\\useUnicode.py'), 'makeisogui.py'],
> pathex=['C:\\fdu-build'])
> a.data += [('/fdu-build/mkisofs.exe','DATA','/temp/mkisofs.exe')]
> pyz = PYZ(a.pure)
> exe = EXE( pyz,
> a.scripts,
> a.binaries,
> a.zipfiles,
> a.datas,

^^^^^^^^

The correct line is something like this:

a.datas += [('\\your\\path\\to\\mkisofs.exe', 'DATA', 'mkisofs.exe')]

Then, you will find the file in the temporary directory whose name is
stored at runtime in os.environ['_MEIPASS2'].

All of this will eventually become smoother of course, it's just a
matter of time :)

--
Giovanni Bajo :: ra...@develer.com
Develer S.r.l. :: http://www.develer.com

My Blog: http://giovanni.bajo.it
Last post: C++ and copy-on-write data structures

Peter Scheie

unread,
Mar 30, 2010, 2:24:00 PM3/30/10
to pyins...@googlegroups.com
Yay, that worked!  Thanks.  Actually, it works but I'm getting some weird behavior.  I first changed the spec file in a directory on the local drive (C:) of my Windows VM, and it worked, as mentioned.  Then, I used the same script, spec file and mkisofs.exe but sitting on a network drive (V:) exported from my Ubuntu box via samba; this time it failed, saying

"Cannot find ("V:\pythonstuff\fdu-build\mkisofs.exe','DATA','mkisofs.exe', 0,'b')
<several lines of traceback>
IOError: [Errno 2] No such file or directory: 'DATA'

I moved the files that worked from the C: drive to the V: drive and they still failed (to prove to myself I didn't have just a typo).  I then moved the files originally on V: to C: and then Build.py ran successfully.  So, I just figured it doesn't like running on a network drive for some reason; I can live with that.  (Python.exe and the pyinstaller files are all on the local C: drive and I've been giving their full paths when I run Build.py.)  Today in the office (I was at home yesterday), I'm trying to do the same thing, but even though I have all the files on the local C:, I'm getting the same "No such file or directory: 'DATA'" error.  Any idea what I'm doing wrong?  Thanks.

Peter

Giovanni Bajo

unread,
Mar 30, 2010, 2:51:08 PM3/30/10
to pyins...@googlegroups.com

Can you please post the complete traceback?

--
Giovanni Bajo :: ra...@develer.com
Develer S.r.l. :: http://www.develer.com

My Blog: http://giovanni.bajo.it

Peter Scheie

unread,
Mar 30, 2010, 3:04:48 PM3/30/10
to pyins...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To post to this group, send email to pyins...@googlegroups.com.
To unsubscribe from this group, send email to pyinstaller...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyinstaller?hl=en.


Here it is.  Note that here I'm trying to include a different file, zeus.p12, into the onefile.

C:\fdu>c:\Python25\python.exe c:\pyinstaller\Build.py copyfile.spec
checking Analysis
checking PYZ
checking PKG
building because outPKG3.toc missing or bad
building PKG outPKG3.pkg
Cannot find ('/fdu/zeus.p12', 'DATA', 0, 'b')

Traceback (most recent call last):
  File "c:\pyinstaller\Build.py", line 1160, in <module>
    main(args[0], configfilename=opts.configfile)
  File "c:\pyinstaller\Build.py", line 1148, in main
    build(specfile)
  File "c:\pyinstaller\Build.py", line 1111, in build
    execfile(spec)
  File "copyfile.spec", line 15, in <module>
    console=True )
  File "c:\pyinstaller\Build.py", line 661, in __init__
    strip_binaries=self.strip, upx_binaries=self.upx, crypt=self.crypt)
  File "c:\pyinstaller\Build.py", line 561, in __init__
    self.__postinit__()
  File "c:\pyinstaller\Build.py", line 196, in __postinit__
    self.assemble()
  File "c:\pyinstaller\Build.py", line 618, in assemble
    archive.build(self.name, mytoc)
  File "c:\pyinstaller\archive.py", line 229, in build
    self.add(tocentry)   # the guts of the archive
  File "c:\pyinstaller\carchive.py", line 235, in add
    s = open(pathnm, 'rb').read()

Peter Scheie

unread,
Mar 30, 2010, 4:07:36 PM3/30/10
to pyins...@googlegroups.com

By the way, in the spec file I've tried multiple syntaxes:
a.datas += [('C:\\fdu\\zeus.p12','DATA','zeus.p12')]
a.datas += [('C:/fdu/zeus.p12','DATA','zeus.p12')]
a.datas += [('\\fdu\\zeus.p12','DATA','zeus.p12')]
a.datas += [('/fdu/zeus.p12','DATA','zeus.p12')]

They all produce the same error, shown in my previous message.

Peter
Reply all
Reply to author
Forward
0 new messages