cx_freeze: 可执行回溯错误

cx_freeze: Executable traceback error

出于某种原因,当我 运行 我的可执行文件时出现此错误:

---------------------------
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
    exec(code, m.__dict__)
  File "splinter1.py", line 8, in <module>
  File "C:\Python34\lib\splinter\browser.py", line 63, in Browser
    return driver(*args, **kwargs)
  File "C:\Python34\lib\splinter\driver\webdriver\firefox.py", line 23, in __init__
    firefox_profile = FirefoxProfile(profile)
  File "C:\Python34\lib\selenium\webdriver\firefox\firefox_profile.py", line 63, in __init__
    WEBDRIVER_PREFERENCES)) as default_prefs:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Admin\Desktop\exe.win32-3.4\library.zip\selenium\webdriver\firefox\webdriver_prefs.json'

---------------------------
OK   
---------------------------

确实如此,cx_freeze的原始版本中缺少webdriver_prefs.json,但我随后将其手动粘贴到library.zip\selenium\webdriver\firefox中,但仍然出现错误。

这是我的安装文件:

import sys
from cx_Freeze import setup, Executable

exe=Executable(
     script="splinter1.py",
     base="Win32Gui",
     icon="icon.ico"
     )
includefiles=[]
includes=[]
excludes=[]
packages=[]
setup(

     version = "1.0",
     description = "No Description",
     author = "Name",
     name = "Bot search",
     options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
     executables = [exe]
     )

这是我的原始脚本:

from splinter import Browser
import contextlib
from selenium.webdriver import Remote
from selenium.webdriver.support import wait
from selenium.webdriver.support.expected_conditions import staleness_of
import time

browser = Browser('firefox')

CurrentR = 12345678

browser.visit('somewebsite')

browser.fill("field1","")
browser.fill("field2","")

browser.fill("field3",CurrentR)

#Find submit button and click
browser.find_by_id('btnSubmit').first.click()

#Wait for new page to load
class MyRemote(Remote):
    @contextlib.contextmanager
    def wait_for_page_load(self, timeout=30):
        old_page = self.find_element_by_tag_name('html')
        yield
        wait(self, timeout).until(staleness_of(old_page))

print('finished')

if browser.is_text_present('No Records Selected'):
    print("No records selected")
else:
    print("Some records exist")


time.sleep(120)

@Thomas K给出了正确答案。我从 Python 中的 Lib 目录复制了整个 selenium 文件夹,并将其粘贴到我的 .exe 所在的同一目录中。