[python-win32] py2exe issues with script using selenium

Ferdinand Sousa ferdinandsousa at gmail.com
Mon Jul 23 17:21:57 CEST 2012


Hi Mark,

I tried extracting the files inside webdriver.xpi into a folder
webdriverxpi and placed it in lieu of the former in the zip file. I had to
tweak some code inside the firefox_profile.py file as well, so that it
would add the files inside the webdriverxpi folder to the current path
environment. Some thing like:

##
---------------------------------------------------------------------------------------------
WEBDRIVER_EXT = "webdriver.xpi" ## changed this to "webdriverxpi"
..... later in the code ....
 if addon == WEBDRIVER_EXT:
            addon = os.path.join(os.path.dirname(__file__), WEBDRIVER_EXT)
##
---------------------------------------------------------------------------------------------

It worked. As in, it now no longer gave the error I was getting initially.
But, I faced some other issue with some xml standard lib being included
elsewhere in the selenium include tree (IIRC it was <python
root>Lib\xml\dom\minidom.py). The issue was similar to that faced earlier,
missing file.

Rather than have to handle every subsequent import issue, I decided to try
a different approach. I ran py2exe with the --skip-archive option, placed
the compressed webdriver.xpi file into the correct location and voila!

Thanks a ton for your help.

What would I have done without you guys?! :-D
Ferdi

PS: Maybe py2exe should include files it does not recognize as is in the
include tree?? Just my 2 cents.


On Wed, Jul 18, 2012 at 8:07 AM, Mark Hammond <skippy.hammond at gmail.com>wrote:

> The problem is a "conflict" between the firefox_profile module and py2exe.
>  firefox_profile is attempting to open 'C:\\Users\\ferdinand\\**
> Desktop\\Landmark_Ops\\dist\\**library.zip\\selenium\\**
> webdriver\\firefox\\webdriver.**xpi' as a regular file (a .xpi file is a
> .zip file, hence the fact zipfile itself is throwing the error), but that
> file doesn't exist as a regular file.
>
> You probably need to look into the source of firefox_profile and see if
> you can tell it where the .xpi file lives.  Then you would take advantage
> of py2exe's "data_files" option to arrange for the .xpi file to be packaged
> as a regular file, then tell firefox_profile where that location is.
>
> HTH,
>
> Mark
>
>
> On 18/07/2012 4:05 AM, Ferdinand Sousa wrote:
>
>> Hi List,
>>
>> My environment: Win 7 Professional 64-bit, Python 2.7 64-bit and
>> appropriate 64-bit libraries installed over that.
>> I downloaded the 64-bit py2exe package. Though I did not specifically
>> download the Distutils package, I guess I have it from having installed
>> 3rd party Python libraries.
>>
>> I'm trying to create a py2exe executable of a script that automates
>> Firefox using selenium webdriver.
>> The script also uses a couple of other libraries including the python
>> imaging library and pywin32.
>>
>> When I try to run the generated exe I get the following traceback: (the
>> 1st 2 lines after the script starts are print statement output)
>>
>> ##----------------------------**------------------------------**
>> ------------------------------**------------------------------**---------
>> C:\Users\ferdinand\Desktop\**Landmark_Ops\dist>make_ELOG.**exe
>> Starting CLI commands
>> CLI output parsed
>> Traceback (most recent call last):
>>    File "make_ELOG.py", line 220, in <module>
>>    File "selenium\webdriver\firefox\**webdriver.pyc", line 51, in
>> __init__
>>    File "selenium\webdriver\firefox\**extension_connection.pyc", line 45,
>> in __init__
>>    File "selenium\webdriver\firefox\**firefox_profile.pyc", line 136, in
>> add_extension
>>    File "selenium\webdriver\firefox\**firefox_profile.pyc", line 289, in
>> _install_extension
>>    File "zipfile.pyc", line 701, in __init__
>> IOError: [Errno 2] No such file or directory:
>> 'C:\\Users\\ferdinand\\**Desktop\\Landmark_Ops\\dist\\**
>> library.zip\\selenium\\**webdriver\\firefox\\webdriver.**xpi'
>> ##----------------------------**------------------------------**
>> ------------------------------**------------------------------**---------
>>
>> I checked the zip folder mentioned in the path and it is missing the
>> webdriver.xpi file.
>> I manually added the missing file into the zip folder from a similar
>> path in my python setup, but it still doesn't work.
>> The start of the traceback ( line 220, in <module> ) refers to the line
>> where I 1st instantiate the Firefox() selenium webdriver automation
>> object.
>>
>> I had earlier tried the same with pyinstaller and faced a similar kind
>> of issue with the same webdriver.xpi file. It that case, pyinstaller
>> used some other file format (not zip) and I was not able to edit that
>> file.
>>
>> The script works quite ok in the normal python environment.
>> Any pointers?
>>
>> Thanks,
>> Ferdi
>>
>>
>> ______________________________**_________________
>> python-win32 mailing list
>> python-win32 at python.org
>> http://mail.python.org/**mailman/listinfo/python-win32<http://mail.python.org/mailman/listinfo/python-win32>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120723/a7e4eacd/attachment.html>


More information about the python-win32 mailing list