Score:4

WSL: when I try to use GUI package get error "Can't open display"

kn flag

I'm running through the tutorial on: https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#5-install-and-use-a-gui-package

After installing X11 applications I try to follow the tutorial and open xeyes:

xeyes &

I get the following response:

Error: Can't open display
NotTheDr01ds avatar
vn flag
Welcome to Ask Ubuntu! Could you run `wsl.exe --version` and add the results in an [edit](https://askubuntu.com/posts/1449804/edit) to your question? Also, is there any more information in the error? If so, please copy and paste the full message. Thanks!
rh1040 avatar
kn flag
I tried this, but get an error message: --version: command not found However using a different command I can see that I am using WSL2 for Ubuntu, if helpful
NotTheDr01ds avatar
vn flag
Okay, so you are on a somewhat older release of WSL that doesn't support `--version`, and may not support GUI applications (if you are using Windows 10). See [Running GUI apps under WSL](https://askubuntu.com/questions/1389908/running-gui-apps-under-wsl) and my answer to a similar question for instructions on how to upgrade to the "Store" release of WSL on Windows 10. If that solves it, let me know by clicking the "This solved my problem" in the header. Otherwise, let me know via comment and we'll investigate further. Thanks!
NotTheDr01ds avatar
vn flag
I do see that the Ubuntu tutorial includes information on installing WSL from the Store, but you may have already had an older release installed and skipped that part.
aqwertya avatar
br flag
This might help. https://github.com/microsoft/WSL/issues/6430 . https://stackoverflow.com/questions/61860208/running-graphical-linux-desktop-applications-from-wsl-2-error-e233-cannot-op
Score:5
gq flag

I had the same problem. What I did was:

  1. close the terminal
  2. re-open a fresh terminal
  3. run wsl --update
  4. relaunch ubuntu ubuntu
  5. run xeyes &

This fixed my problem.

rh1040 avatar
kn flag
Alas, I tried this and it didn't solve the problem. Thanks very much for the suggestion nonetheless.
Score:3
cn flag

Open C:\Users\username\.wslconfig

Find the line: guiApplications=false and change it to guiApplications=true. If you can not find the line, add it in the file.

Restart your PC.

bkakilli avatar
cn flag
Thanks. Restarting only the wsl was sufficient for me. `wsl -shutdown` then `wsl`. No need to reboot.
Score:0
no flag

if you use core i chip of F series(core i5-9400F), you must install GPU (ubutun version must be 20.04 or later) see: https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#1-overview

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.