I have a python program which uses selenium package, and when creating an exe from this using pyinstaller it creates the exe correctly. When trying to open firefox from this app I got the following error:
IOError: [Errno 2] No such file or directory: 'C:\\users\\mohamed\\Temp\\_MEI622\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
I found this solution, but it doesn't work for me:
Py2exe isn't copying webdriver_prefs.json into builds
Any ideas?
I found a solution for same, when freezing scripts to exe don't use --onefile , use --onedir instead , it will generate one folder for all files and then copy selenium folder in path c:\python27\lib\site-packages\selenium to your app folder and it works correctly
simply include these (.json & .xpi) files as arbitrary files in your .spec file.
here's what worked for me (you might need to change the paths):
needed_selenium_files = [(r'selenium\webdriver\firefox\webdriver_prefs.json',
r'C:\Anaconda\Lib\site-packages\selenium\webdriver\firefox\webdriver_prefs.json',
'DATA'),
(r'selenium\webdriver\firefox\webdriver.xpi',
r'C:\Anaconda\Lib\site-packages\selenium\webdriver\firefox\webdriver.xpi',
'DATA')]
and later on:
coll = COLLECT(exe, a.binaries, needed_selenium_files, ...)
read more on PyInstaller Manual: http://pythonhosted.org/PyInstaller/#toc-class-table-of-contents and http://pythonhosted.org/PyInstaller/#adding-files-to-the-bundle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With