无法在PythonAnywhere上使用Selenium



我正在尝试在PythonAnywhere上安装一个使用Selenium和Chrome的python应用程序。一切都在开发环境中工作,但我在尝试部署到PythonAnywhere时遇到了问题。在尝试运行代码时,我得到了以下回溯:

Traceback (most recent call last):
File "/home/mattk/Door_Price/main.py", line 51, in <module>
main()
File "/home/mattk/Door_Price/main.py", line 13, in main
catalog = Catalog(silent=True)
File "./driver.py", line 29, in __init__
self.driver = self._create_engine(path or config.PATH, silent)
File "./driver.py", line 60, in _create_engine
driver = Chrome(
File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
RemoteWebDriver.__init__(
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, 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/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}),platform=Linux 5.4.0-1020-aws x86_64)

不确定PythonAnywhere是否需要一些特殊配置?如果能在这个问题上提供任何帮助,我们将不胜感激。

导致错误的代码:@静态法def_create_engine(路径,静默(:"quot"生成硒引擎"quot;

# TODO check if driver is present
if silent:
options = ChromeOptions()
options.add_argument('--headless')
driver = Chrome(
executable_path=path,
options=options
)
else:
driver = Chrome(
executable_path=path
)
return driver

已解决。PythonAnyWhere需要在帐户上启用一些测试版功能。

默认情况下,您不能在Chrome上使用PythonAnywhere和Selenium,您需要Firefox 17。检查此项:https://help.pythonanywhere.com/pages/selenium/

您的提交有点令人困惑。我认为要在蟒蛇上安装任何需要添加";用户";旗帜你试过这个吗?:

pip3 install [package] --user

在您的情况下:

pip3 install selenium --user

但从你的回溯来看:

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/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}),platform=Linux 5.4.0-1020-aws x86_64)

看起来硒已经安装好了。

相关内容

  • 没有找到相关文章

最新更新