我成功地将chromedriver与pyinstaller捆绑在一起(尽管不幸的是,在我运行exe后,我的病毒扫描程序将其标记了出来,但这是另一个问题)
我猜您的问题是您没有在脚本中使用WebEx驱动程序提供正确的路径(使用关键字execute_path)。另外,我不确定如何将chromedriver包含在数据文件中。
这是我的例子。
sel_ex.py:
from selenium import webdriverimport os, sys, inspect # http://stackoverflow.com/questions/279237/import-a-module-from-a-relative-pathcurrent_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe() ))[0]))def init_driver(): chromedriver = os.path.join(current_folder,"chromedriver.exe") # via this way, you explicitly let Chrome know where to find # the webdriver. driver = webdriver.Chrome(executable_path = chromedriver) return driverif __name__ == "__main__": driver = init_driver() driver.get("http://www.imdb.com/")sel_ex.spec:
....binaries=[],datas=[("chromedriver.exe",".")],....以这种方式,chromedriver被存储在主文件夹中,尽管它的存储位置无关紧要,只要脚本通过关键字execute_path的正确路径即可。
免责声明:-我没有使用单一文件设置,但这没有什么区别。-我的操作系统是Windows



