Tk initialization failed: no display name and no $DISPLAY environment variable - linux

I am trying to invoke the tool on Centos server from the Ubantu terminal.I am getting the following error.
Tk initialization failed: no display name and no $DISPLAY environment variable.
Please Help me with this.Thanks in advance.

Connect to your CentOS machine with ssh -Y which (per man ssh)
Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.
That will allow your Tk process to connect to X11 on your Ubuntu machine.

I work on Ubuntu. I had the same problem while using gitk on remote machines.
So I tried following
ssh <username>#ip and ran gitk& got the "no display name and no $DISPLAY environment variable." error
ssh -X <username>#ip and ran gitk& it worked!
ssh -Y <username>#ip and ran gitk& it worked!
Thanks for the solution by Elliott Frisch.

I was having same issue using gitk on a new local machine with Ubuntu 21.04 and this solved my problem
export DISPLAY=:0

Related

Pycharm Startup Error: Unable to detect graphics environment

I'm trying to setup Pycharm professional edition on Fedora 25 x64.
After downloading the files and extracting them, I'm trying to run the script ./pycharm.sh in the bin directory.
This is the error I get:
Startup Error: Unable to detect graphics environment
I have checked my Java version
[root#localhost bin]# java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
I tried as well to set the DISPLAY variable:
export DISPLAY=:0
And this is what I get:
[root#localhost bin]# ./pycharm.sh
No protocol specified
Start Failed: Failed to initialize graphics environment
java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
Any suggestions please ?
I had the same error installing in a clean Ubuntu 17.10, with Gnome on Wayland. At #mattdm's suggestion in your comments, I just opened a new terminal (as myself, not root) and it ran fine. I was running as root (after unpacking everything to /opt/) when I got the error.
mike#feynman:~$ /opt/pycharm/bin/pycharm.sh
Once you register/activate, just click the "* Configure v" pulldown from the welcome window, and select "Create Desktop Entry" to make it available from your OS menus. I'm assuming JetBrains made this work for whichever linux flavor you prefer.
Your X environment is not properly set (manually setting DISPLAY doesn't always work). Possibly because you're attempting this as root and root is not the owner of the graphics session. There could be other reasons, too.
You won't be able to run xclock or any other X app either in this situation - this is the clue that it's not a pycharm-related problem. For example if you ssh to localhost as root, not as the user currently logged in into the graphical session:
laptop:~ # ssh localhost
Password:
Last login: Thu Nov 23 22:19:06 2017 from localhost
Have a lot of fun...
laptop:~ # export DISPLAY=:0
laptop:~ # xclock
No protocol specified
Error: Can't open display: :0
laptop:~ # konsole
No protocol specified
Segmentation fault
laptop:~ # pycharm
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
No protocol specified
Start Failed: Failed to initialize graphics environment
You'd also see the same behaviour if you attempt the same in a text-mode console.
To address this issue open a new terminal from the graphics environment - if it is properly installed you should be able to run any of the X apps, including pycharm (or at least it shouldn't fail with that error).
In fedora
I have installed pycharm using fedy. This is worked.
Or change to a another user and try except root.
Phpstrom, Webstrom, PyCharm
Above three of them worked same like that.
In my case I am runing pycharm through docker, which is different host, run command xhost + , this would disable access control and client would be able to connect from any host.
Try running the program from another user instead of root. It worked for me.
I used OpenJDK instead of Oracle Java, because PyCharm hangs on Raspberry Pi.
In the file /etc/java-8-openjdk/accessibility.properties, disabling the entry assistive_technologies (simply comment out with a #) solved the issue.
This is what resolved my issue:
export DISPLAY='localhost:11'

How can I open a x-window application on a remote machine and make that window shown in my local machine

I have a remote server running Linux and I am using macOS. I can connect to that server through ssh command. I noticed that ssh -X is used to enable X11 forwarding. So I tried to connect to that server by running ssh -X name#ip-address command and launched an application on the connection terminal. I expect that window should be shown on my macOS but it didn't. Is there any other configuration I need to set in other to make the X11 forward works?
Macs don't run their GUI in X. You need to install XQuartz first.

QXcbConnection: Could not connect to display Aborted, when installing QT on linux

I am trying to install Qt on a Linux machine remotely from a Windows machine using PuTTY.
When I run the command to install Qt on Linux I get the following error:
~/QT# ./qt-unified-linux-x64-2.0.4-online.run
QXcbConnection: Could not connect to display
Aborted
Please suggest any workaround.
You can use the software repository of that Linux distribution.
For example, if it's Debian or Ubuntu:
sudo apt-get install qtbase5-dev
But if you really want to use the installer (usually, when specific Qt version is needed), then try one of the options:
run an X server on that machine
use the --script option of the online installer (you'll have to write a script like here: https://stackoverflow.com/a/34032216/4742108), it will probably need UI anyways
see if the offline installer has an option to run without UI
refer to here: https://community.nxp.com/message/532966
maybe use the cmd "export DISPLAY=:0" and it works
Try to connect with ssh to the host machine using -X to enable X11 display:
ssh <username>#<ip> -X
aqtinstall is a good option: https://github.com/miurahr/aqtinstall
It's a simple command line tool to download and install any Qt version. It's a fork of my old qli-installer script.

Cannot display xclock program on xserver client - Mobaxterm

I am using Mobaxterm(free version) on a windows 7 desktop to connect to a SUSE 11 Enterprise server on AWS. I am trying to display the xclock program on my xtrem client but I get an error saying 'Error: Can't open display:'. I have used the following syntax to set the display on the server:
export DISPLAY=<IP_addr>:0.0
SUSE 11 does not come with xclock by default so I had to download it and install it.
The hosts file on my PC has the localhost entry commented out, I am not sure if that would make a difference. Any ideas on how to debug this? Thanks.
Fixed!
Earlier I was just looking at xclock program's error msg. But when I scanned Mobaxterms client terminal's output, I found the following msg:
X11 forwarding request failed on channel 0
After some google hunting, found that one of the reasons this happens is when xauth package is not installed on the remote server. So, I checked and found that to be the case. This is the command I ran:
zypper in -name xorg*
This command tells you if the package is installed and if any dependencies exist. The package comes bundled with the xclock program. So zypper uninstalled the other xclock I had installed from another source and replaced it with the right version.
Link to package info:
https://www.suse.com/LinuxPackages/packageRouter.jsp?product=server&version=11&service_pack=&architecture=i386&package_name=xorg-x11-xauth
I also modified a file called /etc/ssh/sshd_config as root. The following lines need to be uncommented:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
And X11UseLocalhost was changed to 'no'. I also changed my security group on AWS to let inbound traffic on port 6000. I am not sure if that matters.
After this mobaxterm automatically set my display parameter to localhost and I was able to run xclock on the remote server and see it on my local PC desktop.

SSH tunnelling into arch box

I have a raspberry pi running arch linux connected to the TV and want to run commands on that screen by SSH'ing from my Ubuntu machine elsewhere.
I have tried running the command SSH -Y root# and starting xclock as a test. However I get the following error:
No protocol specified
Error: Can't open display: :0
I then tried running "export DISPLAY=:0" on the arch machine, but this doesn't solve the issue.
I have X running fine and can see it on the TV and I have edited the file /etc/ssh/ssh_config to allow X11 forwarding.
Anyone know what I am doing wrong?
Many thanks
The ArchLinux wiki has some good instructions on setting things up. I struggled for a while until I found them, but for me the key was to set up SSH forwarding within sshd_config (most distros seem to enable this by default, but Arch doesn't).
Once you've enabled X forwarding in SSHD, I also found it helpful to install the dummy video driver for Xorg ("pacman -S xf86-video-dummy"), which gets rid of irritating errors about missing the RANDR extension. This might not be necessary if you already have it running a real X server locally on the Pi - personally, I'm running mine completely headless.
I've found that I don't have to worry about setting up the DISPLAY variable, or xhost, when running with 'ssh -X' from an iMac. I'd expect Ubuntu to behave the same.
looks like an authentication problem. The answer used to be
xhost +
on the console of the X display. Might help.
You probably want to set
export DISPLAY=[IP_ADDRESS_OF_ARCH_BOX]:0
on your Ubuntu box, then when you run xclock from your Ubuntu box, it'll forward the screen to the Arch box.

Resources