Azure 机器学习在管道上安装 chromedriver
Azure Machine Learning installing chromedriver on a pipeline
我正在尝试 运行 我的 python 脚本(使用 chrome 驱动程序)在管道上以便能够从 Azure 数据工厂调用它。
当我 运行 管道时,我收到 chrome 驱动程序不在路径上的错误。该脚本适用于我的本地环境。我还尝试根据 python 脚本中的以下代码安装 chrome 驱动程序。
import os
os.system('sudo apt-get install unzip')
os.system('wget -N https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip -P ~/Downloads')
os.system('unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads')
os.system('sudo mv -f ~/Downloads/chromedriver /usr/local/share/')
os.system('sudo chmod +x /usr/local/share/chromedriver')
os.system('sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver')
os.system('sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver')
我如何在脚本中调用 chrome 驱动程序:
options= Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('window-size=1920,1080')
options.add_argument('--headless')
options.add_experimental_option('w3c', False)
driver = webdriver.Chrome(executable_path=r'/usr/bin/chromedriver',chrome_options=options)
我运行管道时的错误:
ActivityFailedException: ActivityFailedException:
Message: Activity Failed:
{
"error": {
"code": "UserError",
"message": "User program failed with WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home\n",
"messageParameters": {},
"detailsUri": "https://aka.ms/azureml-run-troubleshooting",
"details": []
},
"time": "0001-01-01T00:00:00.000Z"
}
InnerException None
ErrorResponse
{
"error": {
"message": "Activity Failed:\n{\n \"error\": {\n \"code\": \"UserError\",\n \"message\": \"User program failed with WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home\n\",\n \"messageParameters\": {},\n \"detailsUri\": \"https://aka.ms/azureml-run-troubleshooting\",\n \"details\": []\n },\n \"time\": \"0001-01-01T00:00:00.000Z\"\n}"
}
}
感谢您的宝贵时间。
使用 dockerfile 创建新环境并根据要求安装 chrome 解决了问题。
我正在尝试 运行 我的 python 脚本(使用 chrome 驱动程序)在管道上以便能够从 Azure 数据工厂调用它。
当我 运行 管道时,我收到 chrome 驱动程序不在路径上的错误。该脚本适用于我的本地环境。我还尝试根据 python 脚本中的以下代码安装 chrome 驱动程序。
import os
os.system('sudo apt-get install unzip')
os.system('wget -N https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip -P ~/Downloads')
os.system('unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads')
os.system('sudo mv -f ~/Downloads/chromedriver /usr/local/share/')
os.system('sudo chmod +x /usr/local/share/chromedriver')
os.system('sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver')
os.system('sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver')
我如何在脚本中调用 chrome 驱动程序:
options= Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('window-size=1920,1080')
options.add_argument('--headless')
options.add_experimental_option('w3c', False)
driver = webdriver.Chrome(executable_path=r'/usr/bin/chromedriver',chrome_options=options)
我运行管道时的错误:
ActivityFailedException: ActivityFailedException:
Message: Activity Failed:
{
"error": {
"code": "UserError",
"message": "User program failed with WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home\n",
"messageParameters": {},
"detailsUri": "https://aka.ms/azureml-run-troubleshooting",
"details": []
},
"time": "0001-01-01T00:00:00.000Z"
}
InnerException None
ErrorResponse
{
"error": {
"message": "Activity Failed:\n{\n \"error\": {\n \"code\": \"UserError\",\n \"message\": \"User program failed with WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home\n\",\n \"messageParameters\": {},\n \"detailsUri\": \"https://aka.ms/azureml-run-troubleshooting\",\n \"details\": []\n },\n \"time\": \"0001-01-01T00:00:00.000Z\"\n}"
}
}
感谢您的宝贵时间。
使用 dockerfile 创建新环境并根据要求安装 chrome 解决了问题。