据我所知,将chromedriver.exe与在 selenium webdriver 上运行的 python 脚本合并或添加。
这是我的代码(python):
# importing packages / modules
import os
import service # This module cannot be installed as it asks for Microsoft Visual C++ 14 to be isntalled on pc
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
# Defining required functions that needs to be used again and again
def init_driver():
chrome_path = os.path.join(os.path.dirname(__file__), 'selenium','webdriver','chromedriver.exe')
service = service.Service(chrome_path) # So, this cannot be used to merge it.
path = webdriver.Chrome(service, options=Options())
driver = init_driver()
以及 cmd 中给出的命令:
pyinstaller --noconfirm --onefile --console --icon "path/to/icon.ico" --add-binary "path/to/chrome/driver;./driver" "path/to/the/python/pythonscript.py"
蝴蝶不菲
相关分类