错误:无法打开display::0 geckodriver selenium



我试图运行一个flask应用程序,当用户输入一个链接时,它运行一个带有该链接的selenium脚本,然后返回一些信息。我现在正在尝试部署它,但在设置X服务器时遇到了一些问题。这是工作很好,几天前不知道为什么它停止工作。当输入一个url时,selenium会遇到一个错误,geckodriverlog文件这样说:

1655398364982   geckodriver INFO    Listening on 127.0.0.1:60701
1655398365537   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "57429" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofileqf4HKQ"
No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0

我在这篇文章中尝试了解决方案,它告诉我通过虚拟帧缓冲区运行服务器,但这样做似乎根本没有帮助。我也在这篇文章中尝试了解决方案,但为我的显示变量编写整个ip给了我同样的错误,也有一个新的错误:

1655398078139   geckodriver INFO    Listening on 127.0.0.1:60065
1655398078684   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "48811" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilelQkVrP"
Unable to init server: Broadway display type not supported: (my_servers_ip):0
Error: cannot open display: (my_servers_ip):0

使用的命令:/home/dummy/project/venv/bin/gunicorn——chdir/home/dummy/project - w9 main:app

我认为帧缓冲应该是正确的方法,问题可能是你使用的命令。试试下面的命令:

xvfb-run -d -s '-screen 0 1920x1080x24' /home/dummy/project/venv/bin/gunicorn --chdir /home/dummy/project -w 9 main:app  # remove -d option or use -a option instead

最新更新