没有桌面系统的ubuntu可以显示python的界面程序吗

各种窗口管理器和美化相关
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

没有桌面系统的ubuntu可以显示python的界面程序吗

#1

帖子 小北0125 » 2018-08-15 11:21

ubuntu 16.04;系统目前只有tty1-6端,没有图像界面。请问能否在没有图像界面的情况下显示基于python的GUI程序结果。
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#2

帖子 astolia » 2018-08-15 12:34

看你的gui后端是什么和你想要怎么显示。对于一般的无显示器的服务器环境而言,跑个xvfb这样的无头xserver,设置一下DISPLAY环境变量,再远程vnc连接就行了
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#3

帖子 小北0125 » 2018-08-16 10:11

astolia 写了: 2018-08-15 12:34 看你的gui后端是什么和你想要怎么显示。对于一般的无显示器的服务器环境而言,跑个xvfb这样的无头xserver,设置一下DISPLAY环境变量,再远程vnc连接就行了
我的ubuntu是运行在arm上的精简版,不是服务器,没有安装桌面环境,利用python的TKinter库写的程序,运行会提示我:_tkinter.TclError: no display name and no $DISPLAY environment variable,然后将设置环境变量设置成:export DISPLAY=:0.0,这个环境变量默认是将图形显示在tty7端下,因此运行有提示can't connect display:0.0 我想是因为没有安装图形界面因此没有tty7。所以我想问可不可以在tty1的字符界面下显示图像,能不能通过设置实现?
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#4

帖子 oneleaf » 2018-08-16 10:27

到本地安装一个Xserver,然后用ssh -X 过去,将图形界面映射到本地电脑上
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#5

帖子 小北0125 » 2018-08-16 10:35

oneleaf 写了: 2018-08-16 10:27 到本地安装一个Xserver,然后用ssh -X 过去,将图形界面映射到本地电脑上
这个设备他是有自己的显示器,我希望得到的结果是在这个设备上的显示器上显示我们运行的结果,而不是通过远程的方式实现。
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#6

帖子 astolia » 2018-08-16 19:36

你需要的就是安装个xserver环境。

代码: 全选

sudo apt install xinit xserver-xorg xserver-xorg-input-all xserver-xorg-video-all
在xsession文件里写上运行你那个程序,然后在用startx启动。
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#7

帖子 小北0125 » 2018-08-20 11:41

astolia 写了: 2018-08-16 19:36 你需要的就是安装个xserver环境。

代码: 全选

sudo apt install xinit xserver-xorg xserver-xorg-input-all xserver-xorg-video-all
在xsession文件里写上运行你那个程序,然后在用startx启动。
请问怎么将我需要运行的文件写在xsession文件中,比如我的文件在/home/username/gui.py 然后我是直接将我的这个路径加到文件的最后面吗?或者我是我的文件gui.py直接放到Xsession.d目录下?
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#8

帖子 astolia » 2018-08-21 19:24

反正要登录,就放到自己的~/.xsession里就是了
整个文件差不多是这样

代码: 全选

#!/bin/sh
exec python /home/username/gui.py
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#9

帖子 小北0125 » 2018-08-21 19:48

astolia 写了: 2018-08-21 19:24 反正要登录,就放到自己的~/.xsession里就是了
整个文件差不多是这样

代码: 全选

#!/bin/sh
exec python /home/username/gui.py
谢谢,这个我明白了。
但是现在我遇到一个新的问题,在我输入startx 命令后,出现错误,
gbm: failed to open any driver (search pahs /usr/lib/aarch64-linux-gnu/dri:$ {ORIGIN}/dri:/usr/lib/dri)
gbm: Last dlopen error:/usr/lib/dri/xilinx_drm_dri.so: cannot open shared object file : No such file or directory
failed to load driver: xilinx_drm
..
..
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
另外在日志中有提示到Failed to load moudle "fbdev" (moudle does not exist ,0)

这个是因为我缺少这个驱动吗?前面你说下载的几个文件我都有安装了。
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#10

帖子 小北0125 » 2018-08-22 9:20

astolia 写了: 2018-08-21 19:24 反正要登录,就放到自己的~/.xsession里就是了
整个文件差不多是这样

代码: 全选

#!/bin/sh
exec python /home/username/gui.py
我的xserver启动失败,在log中有几个错误
(EE)systemd-logind: failed to get session :Failed to activate service 'org.freedesktop.login1' :timed out
....
...
(EE) modeset (0): glamor initialization failed
.....
...

(EE) modeset (0):failed to set mode :Invalid argument
(EE) Fatal server error :
(EE) AddScreen/ScreenLnit failed for driver 0
...
(EE)Server terminated with error (1). Closing log file

请问这个是我还有什么配置没有做吗?或者其他哪里有什么问题
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#11

帖子 astolia » 2018-08-22 10:23

代码: 全选

grep CONFIG_DRM_XILINX /boot/config-$(uname -r)
看有没有输出CONFIG_DRM_XILINX=y。如果没有输出,说明ubuntu的内核不支持,你可能只有去安装xilinx自家的 http://www.wiki.xilinx.com/Zynq%202018.2%20Release
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#12

帖子 小北0125 » 2018-08-22 11:30

astolia 写了: 2018-08-22 10:23

代码: 全选

grep CONFIG_DRM_XILINX /boot/config-$(uname -r)
看有没有输出CONFIG_DRM_XILINX=y。如果没有输出,说明ubuntu的内核不支持,你可能只有去安装xilinx自家的 http://www.wiki.xilinx.com/Zynq%202018.2%20Release
我这边输出的结果是grep: /boot/config-4.9.0: No such file or directory
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#13

帖子 astolia » 2018-08-22 14:31

你是用的自编译内核?编译内核时要把相关的东西编译进去才行 http://www.wiki.xilinx.com/Xilinx+DRM+KMS+driver
小北0125
帖子: 17
注册时间: 2018-08-15 11:11
系统: ubuntu16.04

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#14

帖子 小北0125 » 2018-09-02 18:56

astolia 写了: 2018-08-22 14:31 你是用的自编译内核?编译内核时要把相关的东西编译进去才行 http://www.wiki.xilinx.com/Xilinx+DRM+KMS+driver
谢谢你的回答。终于解决了。
另外想请问你一个不是这个板块的问题,
我想在arm上安装PyQt4,不知道您有没有经验,现在sip的默认是linux-g++。当我改成linux-arm-gcc时,我发现我安装的arm-linux-gcc是只能在x86下运行。也就是导致我无法安装sip。不知您有没有这方面安装的建议?
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 没有桌面系统的ubuntu可以显示python的界面程序吗

#15

帖子 astolia » 2018-09-03 9:57

如果你还在用ubuntu,那么源里有现成的
sudo apt install python-qt4
回复