简体   繁体   English

pyinstaller不导入chrome webdriver? 硒

[英]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. 我正在使用pyinstaller为要在另一台计算机上使用的脚本创建一个.exe,问题是在编译时它会导入webdriver / firefox,而不会导入该脚本使用的chrome webdriver,因此.exe将不会跑。 I'm just wondering why this is happening and how I can fix this. 我只是想知道为什么会这样以及如何解决这个问题。 I am using python 3.5 我正在使用python 3.5

Download Chrome Driver for your machine from here: http://chromedriver.storage.googleapis.com/index.html?path=2.20 从此处下载适用于您计算机的Chrome驱动程序: 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): 然后,您可以通过以下方式使用Chrome驱动程序(端口可能有所不同):

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 : 通过在脚本中显式导入selenium.webdriver.Chrome ,可以解决同一问题:

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

I guess pyinstaller will not then forget this Chrome sub-module. 我想pyinstaller不会再忘记此Chrome子模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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