7

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
rh1040
  • 71
  • 1
    Welcome to Ask Ubuntu! Could you run wsl.exe --version and add the results in an edit to your question? Also, is there any more information in the error? If so, please copy and paste the full message. Thanks! – NotTheDr01ds Jan 11 '23 at 17:25
  • 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

    – rh1040 Jan 13 '23 at 16:31
  • 1
    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 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 Jan 14 '23 at 05:12
  • 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. – NotTheDr01ds Jan 15 '23 at 04:25
  • 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 – aqwertya Jun 02 '23 at 10:10

4 Answers4

10

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.

  • 2
    Alas, I tried this and it didn't solve the problem. Thanks very much for the suggestion nonetheless. – rh1040 Jan 13 '23 at 16:32
5

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 (or just do wsl --shutdown followed by wsl as suggested by @bkakilli).

0

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

0

I had the same problem yesterday. What fixed it today was:

  1. Upgrading WSL to WSL2 (https://www.scaler.com/topics/linux-terminal-for-windows/)
  2. Installing Xming for Windows (https://sourceforge.net/projects/xming/)

After steps 1 & 2 I still got the "Can't open display" error

  1. Section 4.2 of the following article explains how to set environment variables (https://datacadamia.com/ssh/x11/display)

After confirming the shell (bash in my case), setting the DISPLAY variable with the following command enabled me to get X11 commands (e.g. xclock etc) to display in Xming:

$ export DISPLAY=localhost:0.0

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – sotirov Nov 30 '23 at 16:48