Hi,

I'm trying to understand how to use data files and I couldn't get these 
simple scripts to work on my mac. 
Suppose I run makePkl.py to obtain two .pkl files in the current folder. 

# makePkl.py

import cPickle

someTxt = 'press any key to continue'

def someFunc():

    m = [2,3,5]

    y = [7,9,4]

    j = m+y

    return j

pklTxt = open('pklTxt.pkl','wb')

cPickle.dump(someTxt, pklTxt)

pklTxt.close()


pklFunc = open('pklFunc.pkl','wb')

cPickle.dump(someFunc(),pklFunc)

pklFunc.close()


Next I would like to use those .pkl files in some other script like 
pklApp.py and package that script for distribution

# pklApp.py

import cPickle as cp


pkl1 = open('pklTxt.pkl', 'rb')

txt = cp.load(pkl1)

pkl1.close()


pkl2 = open('pklFunc.pkl', 'rb')

returnVal = cp.load(pkl2)

pkl2.close()


print txt, returnVal


I then create a pklApp.spec file and manually edit it to obtain:

# -*- mode: python -*-

a = Analysis(['pklApp.py'],

             pathex=['/smallTests'], # Edit this path for your machine

             hiddenimports=[],

             hookspath=None,

             runtime_hooks=None)

pyz = PYZ(a.pure)

exe = EXE(pyz,

          a.scripts,

          exclude_binaries=True,

          name='pklApp',

          debug=False,

          strip=True,

          upx=True,

          console=False )

coll = COLLECT(exe,

               a.binaries,

               a.zipfiles,

              
 
a.datas+[('pklTxt.pkl','pklTxt.pkl','DATA'),('pklFunc.pkl','pklFunc.pkl','DATA')],

               strip=True,

               upx=True,

               name='pklApp')

app = BUNDLE(coll,

             name='pklApp.app',

             icon=None)


Then when I build the app using the .spec file I can see the .pkl files 
copied into dist/pklApp/ but when I run pklApp.app I get an error in the 
mac console: IOError: [Error no 2] No such file or directory: 'pklTxt.pkl' 


I was expecting the console to show: press any key to continue [2, 3, 5, 7, 
9, 4]

I am certainly making some newbie mistake... please help me figure out the 
mistake. 

Thanks,

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to