Python Forum

Full Version: How to include folder in exe with Pyinstaller?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I 'm trying to include a folder containing phantomjs in my exe I' making with Pyinstaller.
I' using this code: Tree('phantomjs-1.9.8-windows'),

My spec file is in the same directory with phantomjs folder (whose name is 'phantomjs-1.9.8-windows').

This is the hole spec file:
# -*- mode: python -*-

block_cipher = None


a = Analysis(['betWS.spec'],
             pathex=['F:\\Documents and Settings\\Administrator\\My Documents\\PycharmProjects\\WS1'],
             binaries=[],
             Tree('phantomjs-1.9.8-windows'),
             datas=[],
             hiddenimports=['sys', 'signal', 'PyQt4.QtGui','PyQt4.QtCore', 'PyQt4.QtWebKit', 'requests', 're', 'time','time.sleep','bs4.BeautifulSoup','bs4.dammit.UnicodeDammit', 'selenium.webdriver', 'os', 'PyQt4.uic', 'wmi'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='betWS',
          debug=False,
          strip=False,
          upx=True,
          console=True )
But I get an error: file <string>, line 9, SyntaxError non-KeyWord arg after keyword arg

Line 9 is the "Tree('phantomjs-1.9.8-windows'),".
How can I fix this?

I found my mistake!!
The code "Tree('phantomjs-1.9.8-windows')," should be added after "a.binaries," and not after "binaries=[]," as I did.
Now it worked!
So the correct spec is:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['betWS.spec'],
            pathex=['F:\\Documents and Settings\\Administrator\\My Documents\\PycharmProjects\\WS1'],
            binaries=[],
            datas=[],
            hiddenimports=['sys', 'signal', 'PyQt4.QtGui','PyQt4.QtCore', 'PyQt4.QtWebKit', 'requests', 're', 'time','time.sleep','bs4.BeautifulSoup','bs4.dammit.UnicodeDammit', 'selenium.webdriver', 'os', 'PyQt4.uic', 'wmi'],
            hookspath=[],
            runtime_hooks=[],
            excludes=[],
            win_no_prefer_redirects=False,
            win_private_assemblies=False,
            cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
            cipher=block_cipher)
exe = EXE(pyz,
         a.scripts,
         a.binaries,
         Tree('phantomjs-1.9.8-windows'),
         a.zipfiles,
         a.datas,
         name='betWS',
         debug=False,
         strip=False,
         upx=True,
         console=True )