如何在Heroku上安装chromedriver?

bbuxkriu  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(147)

我尝试了很多变体。但是没有一个有效的。例如,https://www.andressevilla.com/running-chromedriver-with-python-selenium-on-heroku/
这是我的日志

Traceback (most recent call last):
2022-06-10T17:38:16.935057+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
2022-06-10T17:38:16.935142+00:00 app[worker.1]:     self.process = subprocess.Popen(cmd, env=self.env,
2022-06-10T17:38:16.935147+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/subprocess.py", line 858, in __init__
2022-06-10T17:38:16.935371+00:00 app[worker.1]:     self._execute_child(args, executable, preexec_fn, close_fds,
2022-06-10T17:38:16.935379+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/subprocess.py", line 1704, in _execute_child
2022-06-10T17:38:16.935735+00:00 app[worker.1]:     raise child_exception_type(errno_num, err_msg, err_filename)
2022-06-10T17:38:16.935765+00:00 app[worker.1]: FileNotFoundError: [Errno 2] No such file or directory: '/app/.chromedriver/bin/chromedriver'
2022-06-10T17:38:16.935769+00:00 app[worker.1]: 
2022-06-10T17:38:16.935769+00:00 app[worker.1]: During handling of the above exception, another exception occurred:
2022-06-10T17:38:16.935770+00:00 app[worker.1]: 
2022-06-10T17:38:16.935770+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-10T17:38:16.935772+00:00 app[worker.1]:   File "avito-bot.py", line 50, in <module>
2022-06-10T17:38:16.935863+00:00 app[worker.1]:     start_bot()
2022-06-10T17:38:16.935876+00:00 app[worker.1]:   File "avito-bot.py", line 47, in start_bot
2022-06-10T17:38:16.935939+00:00 app[worker.1]:     bot.polling(none_stop=True, interval=0)
2022-06-10T17:38:16.935955+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/telebot/__init__.py", line 620, in polling
2022-06-10T17:38:16.936166+00:00 app[worker.1]:     self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
2022-06-10T17:38:16.936178+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/telebot/__init__.py", line 694, in __threaded_polling
2022-06-10T17:38:16.936386+00:00 app[worker.1]:     raise e
2022-06-10T17:38:16.936398+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/telebot/__init__.py", line 650, in __threaded_polling
2022-06-10T17:38:16.936590+00:00 app[worker.1]:     self.worker_pool.raise_exceptions()
2022-06-10T17:38:16.936602+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/telebot/util.py", line 143, in raise_exceptions
2022-06-10T17:38:16.936678+00:00 app[worker.1]:     raise self.exception_info
2022-06-10T17:38:16.936680+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/telebot/util.py", line 89, in run
2022-06-10T17:38:16.936744+00:00 app[worker.1]:     task(*args, **kwargs)
2022-06-10T17:38:16.936756+00:00 app[worker.1]:   File "avito-bot.py", line 44, in handle_text
2022-06-10T17:38:16.936817+00:00 app[worker.1]:     answer = f'{find(message.text)}'
2022-06-10T17:38:16.936829+00:00 app[worker.1]:   File "/app/parsing.py", line 21, in find
2022-06-10T17:38:16.936888+00:00 app[worker.1]:     driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), chrome_options=chrome_options)
2022-06-10T17:38:16.936900+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
2022-06-10T17:38:16.936967+00:00 app[worker.1]:     super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
2022-06-10T17:38:16.936979+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 89, in __init__
2022-06-10T17:38:16.937048+00:00 app[worker.1]:     self.service.start()
2022-06-10T17:38:16.937060+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
2022-06-10T17:38:16.937126+00:00 app[worker.1]:     raise WebDriverException(
2022-06-10T17:38:16.937154+00:00 app[worker.1]: selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
gk7wooem

gk7wooem1#

我很惊讶。我不得不下载chromedriver并把它放在目录中。但我想,那个buildpack应该可以做到。

相关问题