【发布时间】:2019-10-19 12:18:15
【问题描述】:
我需要添加 gecko 驱动程序以便在 Azure 上运行无头浏览器作为我网站的一部分,但我需要将 geckodriver 添加到 PATH(显然我无法在 Python 中手动输入 geckodriver 文件的位置?)
我知道我必须使用 applicationHost.xdt 文件并将其添加到 /home/site 文件夹,但我的 Kudu 页面不允许我添加文件(我可以使用 'touch' 创建文件,但我可以'不要编辑它)。
这就是我的 Kudu 页面的样子:https://imgur.com/a/99oHUoC
这是我的 applicationHost.xdt:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing">
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="geckodriver" value="geckodriverL" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="PATH" value="%PATH%;%HOME%\site\wwwroot\cpu" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</environmentVariables>
</runtime>
</system.webServer>
</configuration>
这是我从 Django 得到的错误:
WebDriverException at /
Message: 'geckodriverL' executable needs to be in PATH.
Request Method: GET
Request URL: http://site.azurewebsites.net/
Django Version: 2.2.6
Exception Type: WebDriverException
Exception Value:
Message: 'geckodriverL' executable needs to be in PATH.
Exception Location: /antenv/lib/python3.7/site-packages/selenium/webdriver/common/service.py in start, line 83
Python Executable: /opt/python/3.7.4/bin/python3.7
Python Version: 3.7.4
Python Path:
['/opt/python/3.7.4/bin',
'/home/site/wwwroot',
'/antenv/lib/python3.7/site-packages',
'/opt/python/3.7.4/lib/python37.zip',
'/opt/python/3.7.4/lib/python3.7',
'/opt/python/3.7.4/lib/python3.7/lib-dynload',
'/opt/python/3.7.4/lib/python3.7/site-packages']
Server time: Fri, 18 Oct 2019 14:39:59 +0000
【问题讨论】:
标签: django python-3.x azure azure-web-app-service kudu