X服务器远程连接问题解决:Bad displayname ““‘或Missing X server or $DISPLAY

文章讲述了在遇到X服务器远程连接问题时,如何解决ImportError,如检查X服务器是否运行,DISPLAY环境变量设置不正确,以及在多用户环境下如何指定显示编号。提到pynput模块对X服务器的依赖,并提供了相应的解决步骤。

X服务器远程连接问题

报错1

ImportError: this platform is not supported: ('failed to acquire X connection: Bad display
 name ""', DisplayNameError('')) Try one of the following resolutions: * Please make sure
 that you have an X server running, and that the DISPLAY environment variable is set 
correctly

这个错误表明程序依赖于 X 服务器,但它无法找到 X 服务器或者 $DISPLAY 环境变量没有设置正确。

在你的情况下,程序在尝试导入 pynput 模块时出现了问题。pynput 模块通常用于捕获键盘输入,它需要一个可用的 X 服务器来工作。

报错2

[2370019:0406/114907.428655:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY 
[2370019:0406/114907.428695:ERROR:env.cc(255)] The platform failed to initialize. Exiting. 
The futex facility returned an unexpected error code.

在多用户环境下,每个用户可以通过设置不同的 DISPLAY 环境变量来指定他们要使用的 X 服务器显示编号。一般来说,X 服务器的显示编号从":0"开始,然后依次递增。当用户启动图形界面应用程序时,程序会根据 DISPLAY 环境变量的值来确定要连接的 X 服务器。

例如,如果用户 A 想在自己的 X 服务器上运行图形界面应用程序,他可以设置 DISPLAY 环境变量为":0",而用户 B 可以将其设置为":1",以此类推。

在多用户系统中,通常会有一些约定或管理工具来协调和分配 X 服务器的显示编号,以确保不同用户之间的图形界面应用程序不会产生冲突。

解决方法

  1. 查看要转发X11服务的服务器编号f526dc9a4f2e403884ca12b746f2e302.png

    ​​​​​​​ps aux | grep Xorg
  2. 指定要使用X11的服务器编号:如果是单用户,指定":0"即可,如果不行,以此类推,可以指定":1"试试;如果是多用户,非服务器本地登录账户,为远程登录账户,根据连接服务器的编号来指定,如上,指定为":10"即可。
    export DISPLAY=:0
    export DISPLAY=:10

     

 

(venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$ curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNzYxNzQ0MTUyLCJqdGkiOiIxNTJiNmI0OS05YjNmLTRjNDItYTlmZS1jMjdlYWNiYjYxNDUiLCJ0eXBlIjoiYWNjZXNzIiwic3ViIjoiMSIsIm5iZiI6MTc2MTc0NDE1MiwiY3NyZiI6IjA4MmI5MzgzLTMwZWQtNGI4OS05NDQyLTBmZjQ2NTNkMzhmOCIsImV4cCI6MTc2MTc0NTA1Mn0.FMzqTkWbqECmoxgyeKlTTmz6CrV924wuS81TaSyTdQc" \ http://192.168.110.204:8088/api/v1/tag/ {"count":0,"description_columns":{},"ids":[],"label_columns":{"changed_by.first_name":"Changed By First Name","changed_by.last_name":"Changed By Last Name","changed_on_delta_humanized":"Changed On Delta Humanized","created_by.first_name":"Created By First Name","created_by.last_name":"Created By Last Name","created_on_delta_humanized":"Created On Delta Humanized","description":"Description","id":"Id","name":"Name","type":"Type"},"list_columns":["id","name","type","description","changed_by.first_name","changed_by.last_name","changed_on_delta_humanized","created_on_delta_humanized","created_by.first_name","created_by.last_name"],"list_title":"List Tag","order_columns":["id","name","type","description","changed_by.first_name","changed_by.last_name","changed_on_delta_humanized","created_on_delta_humanized","created_by.first_name","created_by.last_name"],"result":[]} (venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$ curl -X POST \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "kiosk", "type": "default" }' \ http://192.168.110.204:8088/api/v1/tag/ {"errors": [{"message": "400 Bad Request: The CSRF token is missing.", "error_type": "GENERIC_BACKEND_ERROR", "level": "error", "extra": {"issue_codes": [{"code": 1011, "message": "Issue 1011 - Superset encountered an unexpected error."}]}}]}(venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kicurl -PUT \PUT \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '["kiosk"]' \ http://192.168.110.204:8088/api/v1/dashboard/2/tags <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=q,initial-scale=1"/><link rel="icon" type="image/png" href="/static/assets/e3bafb62eb2592c0bb0e.png"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" rel="stylesheet"/><style>html { height: 100%; } body { color: #1985a0; font-family: 'Inter', sans-serif; height: 100%; margin: 0; display: flex; align-items: stretch; } h1 { font-weight: 600; font-size: 88px; margin: 0; } p { font-weight: 500; font-size: 24px; line-height: 40px; width: 490px; } .button { -webkit-appearance: button; -moz-appearance: button; appearance: button; background-color: #1985a0; /* Green */ border: none; color: white; padding: 16px 38px; text-align: center; text-decoration: none; display: inline-block; font-size: 11px; border-radius: 4px; text-transform: uppercase; } .error-page-content { display: flex; flex-direction: row; align-items: center; justify-content: space-between; max-width: 1350px; margin: auto; width: 100%; padding: 56px; } img { width: 540px; }</style><title>404: Not found | Superset</title></head><body><div class="error-page-content"><section><h1>Page not found</h1><p>Sorry, we cannot find the page you are looking for. You may have mistyped the address or the page may have moved.</p><a href="/" class="button">Back to home</a></section><img alt="404" src="/static/assets/1a1474519a0ea853fdce.png" width="540"/></div></body></html>(venv) gapinyc@DESKTOP-9QS7RL5:~/superset-kiosk$
最新发布
10-30
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值