【发布时间】:2019-04-15 07:24:36
【问题描述】:
我有一个 python selenium 脚本。我想在远程连接(使用 ssh)PC 上运行脚本。当我直接在该 PC 上运行脚本时,它会运行。但是,当我远程运行相同的脚本时,它会抛出错误。
Traceback (most recent call last):
File "crawling_script.py", line 14, in <module>
driver = webdriver.Chrome(executable_path='/var/www/html/hariharan/health_grades/chromedriver')
File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.4.0-145-generic x86_64)
请给我一个远程运行 selenium python 脚本的解决方案。 提前致谢。
【问题讨论】:
-
答案在错误信息中:
Chrome failed to start: exited abnormally。您能检查一下您要执行的文件中的内容吗 (executable_path=/var/www/html/hariharan/health_grades/chromedriver)? -
文件可用。我可以直接在电脑上运行脚本。但不能远程运行。
标签: python selenium selenium-webdriver