I wrote a simple application that uses selenium for nagivate through pages and downloads their source code. Now I would like to make my application executable Windows.
My setup.py file:
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 1, "dll_excludes": ['w9xpopen.exe', 'MSVCP90.dll', 'mswsock.dll', 'powrprof.dll', 'MPR.dll', 'MSVCR100.dll', 'mfc90.dll'], 'compressed': True,"includes":["selenium"], } }, windows = [{'script': "main.py", "icon_resources": [(1, "hacker.ico")]}], zipfile = None )
My program ( main.py ) (with setup.py ) is located in C:\Documents and Settings\student\Desktop . Py2exe builds my exe in C:\Documents and Settings\student\Desktop\dist .
I copied the webdriver.xpi and webdriver_prefs.json to C:\Documents and Settings\student\Desktop\dist\selenium\webdriver\firefox\ , but I get an error when I try to start the application:
Traceback (most recent call last): File "main.py", line 73, in <module> File "main.py", line 58, in check_file File "main.py", line 25, in try_to_log_in File "selenium\webdriver\firefox\webdriver.pyo", line 47, in __init__ File "selenium\webdriver\firefox\firefox_profile.pyo", line 63, in __init__ IOError: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\student\\Desktop\\dist\\main.exe\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
How to solve this?
Actually, he worked with the setup.py :
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') wd_path = 'C:\\Python27\\Lib\\site-packages\\selenium\\webdriver' required_data_files = [('selenium/webdriver/firefox', ['{}\\firefox\\webdriver.xpi'.format(wd_path), '{}\\firefox\\webdriver_prefs.json'.format(wd_path)])] setup( windows = [{'script': "main.py", "icon_resources": [(1, "hacker.ico")]}], data_files = required_data_files, options = { "py2exe":{ "skip_archive": True, } } )
But the problem is that I need to create a SINGLE executable.