【问题标题】:How to add an executable to PATH in Azure's Kudu?如何在 Azure 的 Kudu 中将可执行文件添加到 PATH?
【发布时间】: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


    【解决方案1】:

    据我所知,根据 Kudu wiki 页面 Azure Web App sandbox,由于 Win32k.sys (User32/GDI32) Restrictions,您不能在 GDI 中使用任何东西,包括无头浏览器,例如带有 Blink 的 Chrome 和带有 Gecko 的 Firefox。

    要修复它,请切换到在 Linux 上使用 Azure VM 或 Azure WebApp(它基于 Docker)。

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 2019-08-17
      • 2012-01-04
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多