Chromedriver错误:[Errno13]权限被拒绝'chromedriver / chromedriver.exe'

问题描述 投票:-1回答:1

我有一个使用Flask的应用程序,它使用Selenium和Chrome webdriver来刮网。当我在本地测试它时它完美无缺。但是,我尝试部署到Heroku,我不断收到以下两个错误:

PermissionError: [Errno13] Permission denied 'chromedriver/chromedriver.exe' 

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

这是我的代码部分,我指的是chromedriver。

options = webdriver.ChromeOptions()
options.add_argument('headless')

browser = webdriver.Chrome(executable_path="chromedriver/chromedriver.exe", chrome_options=options)
browser.get('https://sis.pleasantonusd.net/StudentPortal')

文件chromedriver.exe位于文件夹chromedriver中,该文件夹与文件GradeScraper.py(带有Selenium代码的文件)齐平。这是目录结构:

QC-Scraper
|- app.py
|- GradeScraper.py
|- Procfile
|- requirements.txt
|- README.md
|- chromedriver
    |- chromedriver.exe
|- templates
    |- grades.html

在结构中,app.py是主要的Flask应用程序,其中调用app.run()函数。 GradeScraper.py是实际抓取代码的一部分,它被导入app.py。我会尽力提供必要的额外信息。非常感谢帮助!

提前致谢!

编辑:我将Windows chromedriver更改为Linux chromedriver并部署它,错误仍然存​​在。

EDIT2:我还在procfile中添加了一个release命令,chmod +x chromedriver/chromedriver。仍然无法正常工作。

python selenium heroku flask
1个回答
0
投票

它告诉你,chromedriver.exe没有设置可执行位。

但我认为这并不重要,因为你试图在Heroku所在的Linux机器上运行Windows程序(.exe)。

© www.soinside.com 2019 - 2024. All rights reserved.