Skip to content Skip to sidebar Skip to footer

Python - Trouble In Building Executable

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 s

Solution 1:

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.

Solution 2:

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.

Solution 3:

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,

)

Solution 4:

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.coreimport 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.

Post a Comment for "Python - Trouble In Building Executable"