简体   繁体   English

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

[英]Chromedriver error: [Errno13] Permission denied 'chromedriver/chromedriver.exe'

I have an app with Flask that uses Selenium with a Chrome webdriver to scrape the web.我有一个带有 Flask 的应用程序,它使用 Selenium 和 Chrome 网络驱动程序来抓取网络。 It works flawlessly when I'm testing it locally.当我在本地测试它时,它完美无缺。 However, I tried deploying to Heroku and I keep getting the following two errors:但是,我尝试部署到 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

This is the section of my code where I refer to the chromedriver.这是我引用 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')

The file chromedriver.exe is in the folder chromedriver , which is level with the file GradeScraper.py (the file with the Selenium code).文件chromedriver.exe位于文件夹chromedriver ,该文件夹与文件 GradeScraper.py(带有 Selenium 代码的文件)相同。 Here is the directory structure:这是目录结构:

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

In the structure, app.py is the main Flask app, where the app.run() function is called.在结构中, app.py是主要的 Flask 应用程序,其中调用了app.run()函数。 GradeScraper.py is the part with the actual scraping code, and it is imported into app.py . GradeScraper.py是实际抓取代码的部分,导入到app.py I'll try my best to provide any extra information necessary.我会尽力提供任何必要的额外信息。 Help would be greatly appreciated!帮助将不胜感激!

Thanks in advance!提前致谢!

EDIT: I changed the Windows chromedriver to a Linux chromedriver and deployed it, the error still persists.编辑:我将 Windows chromedriver 更改为 Linux chromedriver 并部署它,错误仍然存​​在。

EDIT2: I also added a release command in the procfile, chmod +x chromedriver/chromedriver . EDIT2:我还在 procfile 中添加了一个 release 命令, chmod +x chromedriver/chromedriver Still doesn't work.还是不行。

It is telling you that chromedriver.exe doesn't have the executable bit set.它告诉您chromedriver.exe没有设置可执行位。

But I don't think that matters since you are trying to run a Windows program (.exe) on an Linux machine which is what Heroku is.但我认为这并不重要,因为您正在尝试在 Heroku 的 Linux 机器上运行 Windows 程序 (.exe)。

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

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