简体   繁体   中英

pyinstaller not importing chrome webdriver? selenium

I'm using pyinstaller to create a .exe for my script to be used on another computer, the issue is when it gets compiled it imports webdriver/firefox it doesn't import the chrome webdriver which the script uses so the .exe won't run. I'm just wondering why this is happening and how I can fix this. I am using python 3.5

Download Chrome Driver for your machine from here: http://chromedriver.storage.googleapis.com/index.html?path=2.20

Run it. And then you can use your Chrome Driver by this way (port may be different):

from selenium import webdriver    
driver = webdriver.Remote('http://localhost:9515', desired_capabilities=DesiredCapabilities.CHROME)

It works fine for me.

I get the same issue fixed by explicitly import the selenium.webdriver.Chrome in my script :

import selenium
from selenium import webdriver
from selenium.webdriver import Chrome

I guess pyinstaller will not then forget this Chrome sub-module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM