7

I'm a python programmer and I'm trying to build an executable binary to distribute my software to my clients, even if it's not fully executable I want to be able to distribute my software in a way so that it is convenient for the end user.

I have already tried PyInstaller as well as Py2Exe and I'm facing the same problem with a particular software.

I used the splinter module for my program (which of course is a new high level framework to interact with other frameworks like Selenium) and every time I try to compile it there seems to be a file called "webdriver.xpi" that is always left out from the final package and therefore when the program attempts to execute the web-driver it fails with an IO Error saying that the file "webdriver.xpi" was not found....but other than that the GUI and everything works perfectly fine.

So is there a way to include it even manually? I tried including it manually by browsing to the specific folder @ library.zip file but it didn't work.

I'm not really expert in this matter and I rely on GUI2Exe for building everything...and I would really appreciate some advice if possible on how to fix this.

Thanks.

4 Answers4

10

I was at this all day and found a workaround, it's sneaky but it works. In the error message I was receiving I noticed that there was a space between in library .zip. I could not trace it down in the source code for py2exe or selenium. I too had tried putting the xpi file in the library zip and it did not work. The workaround is:

  1. In your setup file use these options:

    setup(
        console=['yourFile.py'],
        options={
                "py2exe":{
                        "skip_archive": True,
                        "unbuffered": True,
                        "optimize": 2
                }
        }
    )
    
  2. Run the py2exe install

  3. Copy the xpi file into the dist directory

That should do it.

relima
  • 3,462
  • 5
  • 34
  • 53
aknatn
  • 673
  • 6
  • 14
  • 1
    I agree with aknatn, I've found the solution to this problem long time ago but totally forgot that I posted the question here. The main solution is whatever you do even with a gui builder like GUI2Exe, just make sure the final package is not zipped or anything and everything is unpacked in a folder to which you can add .xpi file manually and make it work. Later I used something like NSIS to package it into a cool installation wizard with license agreements, key files, etc. to distribute it to third parties. I must say I've learned a lot from messing around, trying to get Python to work :) – Chacha Chowdhury May 13 '12 at 01:06
  • Lol I did try that...it says Vote Up requires 15 reputation xD – Chacha Chowdhury May 14 '12 at 23:39
  • 2
    Rather than manually copying them, why not use the `py2exe` setup option `datafiles=[('path/copy/them/to', ['list/of/file/paths/this.txt'])]`? – nerdwaller Jan 17 '14 at 15:16
1

Here is a solution of your question: I have modify a code little and it should be work since I had a same issue and I solved it:

from distutils.core import setup
import py2exe

wd_base = 'C:\\Python27\\Lib\site-packages\\selenium-2.44.0-py2.7.egg    \\selenium\\webdriver'
RequiredDataFailes = [
('selenium/webdriver/firefox', ['%s\\firefox\\webdriver.xpi'%(wd_base), '%s\\firefox\\webdriver_prefs.json'%(wd_base)])
]

setup(
windows=[{"script":"gui_final.py"}],options={"py2exe":{"skip_archive": True,"includes":["sip"]}},
data_files=RequiredDataFailes,

)
gaurang
  • 11
  • 1
1

You need an instruction in your setup.py to include any resource files in your distribution. There is a couple of ways of doing this (see distutils, setuptools, distribute - depending on what you are using to build your distribution), but the py2exe wiki has an example.

You may need to use this py2exe tip to find your resources if you're installing them into the same directory as your exe.

See this answer for some additional info on including resource files in your distribution.

Community
  • 1
  • 1
Mark Gemmill
  • 5,889
  • 2
  • 27
  • 22
0

I know this is old, but I wanted to give an updated answer to avoid suggesting that programmers do something manually.

There is a py2exe option to specify a list of data files as tuples. (pathtocopyto, [list of files and where to get them])

Example:

from disutils.core import setup
import py2exe

wd_base = 'C:\\Python27\\Lib\\site-packages\\selenium\\webdriver'
RequiredDataFailes = [
    ('selenium/webdriver/firefox', ['%s\\firefox\\webdriver.xpi'%(wd_base), '%s\\firefox\\webdriver_prefs.json'%(wd_base)])
]

setup(
    console=['MyScript.py'],
    data_files=RequiredDataFiles,
    options={
        **mypy2exeopts
    }
)

The only downside I am aware of currently is that you still need skip_archive = True. There are workarounds to get the data files in the library.zip, but I haven't had much luck with the webdriver's info.

nerdwaller
  • 1,813
  • 1
  • 18
  • 19