Heroku未知错误:找不到Chrome二进制文件

时间:2017-11-23 09:38:43

标签: python google-chrome selenium heroku

我添加了以下heroku-buildpack: google-chrome是一个heroku-buildpack-chromedriver 然后我设置环境变量

GOOGLE_CHROME_BIN = /app/.apt/opt/google/chrome/chrome
GOOGLE_CHROME_SHIM = /app/.apt/usr/bin/google-chrome-stable

我得到了以下信息:

Exception Type: WebDriverException
Exception Value:
Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 3.13.0-133-generic x86_64)
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response, line 194

我很挣扎,不知道我做错了什么? 我怎么知道我是否正确设置了变量的路径?

1 个答案:

答案 0 :(得分:0)

现在它的工作很有意思,doe是我完成的步骤 我将环境变量设置为folow(你可以通过heroku dashbord - >设置来实现)

GOOGLE_CHROME_BIN =/app/.apt/opt/google/chrome/google-chrome
GOOGLE_CHROME_SHIM= /app/.apt/opt/google/chrome/google-chrome

然后在我的djanogo项目中,我想运行selenuim

from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions

chrome_bin = os.environ.get('GOOGLE_CHROME_SHIM', None)
opts = ChromeOptions()
opts.binary_location = chrome_bin
driver = webdriver.Chrome(executable_path="chromedriver", 
chrome_options=opts)# webdriver.Chrome(DRIVER)
driver.get(url)
....

我得到了https://github.com/heroku/heroku-buildpack-google-chrome/issues/26#issuecomment-346647415

的frbry的帮助