Skip to content Skip to sidebar Skip to footer

Webdriverprefs.json Not Found - Pyinstaller

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

Solution 1:

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

Solution 2:

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

Solution 3:

In my experience, pyinstaller always messes something up when creating executables. I suggest that you use py2exe instead.

Post a Comment for "Webdriverprefs.json Not Found - Pyinstaller"