Win 10 WSL xLaunch AFNI GUI Error

Hello all,

Have recently downloaded and prepped AFNI on new Win10 machine (use WSL), which I’ve done once before. In early part of install, following documentation’s instructions, typed ‘afni’ and the GUI popped up correctly. And yes, have xLaunch installed and run that before running Ubuntu. Display number was set to -1 to let xLaunch choose automatically. I’m also running two monitors.

Also made sure that I had/did this:

echo "export DISPLAY=:0.0" >> ~/.bashrc
echo "setenv DISPLAY :0.0" >> ~/.cshrc
echo "export NO_AT_BRIDGE=1" >> ~/.bashrc
echo "setenv NO_AT_BRIDGE 1" >> ~/.cshrc

Output of ‘ -check_all’ is as follows:

PatrickDesktop:~> -check_all
-------------------------------- general ---------------------------------
architecture: 64bit ELF
system: Linux
release: 4.19.104-microsoft-standard
version: #1 SMP Wed Feb 19 06:37:35 UTC 2020
– failed platform.linux_dist()
distribution: ubuntu 20.04 focal
number of CPUs: 12
apparent login shell: tcsh
shell RC file: .cshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /home/patreyes/abin/afni
afni version : Precompiled binary linux_ubuntu_16_64: Aug 4 2020
: AFNI_20.2.10 ‘Aulus Vitellius’
AFNI_version.txt : AFNI_20.2.10, linux_ubuntu_16_64, Aug 04 2020
which python : /usr/bin/python
python version : 3.8.2
which R : /usr/bin/R
R version : R version 3.6.3 (2020-02-29) – “Holding the Windsock”
which tcsh : /usr/bin/tcsh

instances of various programs found in PATH:
afni : 1 (/home/patreyes/abin/afni)
R : 1 (/usr/bin/R)
python : 1 (/usr/bin/python3.8)
python2 : 0
python3 : 1 (/usr/bin/python3.8)

** have python3 but not python2

testing ability to start various programs…
afni : success
suma : success
3dSkullStrip : success : success
3dAllineate : success
3dRSFC : success
SurfMesh : success
3dClustSim : success
3dMVM : success

checking for R packages…
rPkgsInstall -pkgs ALL -check : success

R RHOME : /usr/lib/R

checking for $HOME files…
.afnirc : found
.sumarc : found
.afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
– PyQt4 is no longer needed for an AFNI bootcamp

++ module loaded: matplotlib.pyplot
module file : /usr/lib/python3/dist-packages/matplotlib/

-------------------------------- env vars --------------------------------
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program:Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2020.424.0_x64__79rhkp1fndgsc:/mnt/c/Python38/Scripts/:/mnt/c/Python38/:/mnt/c/Program:Files/dotnet/:/mnt/c/Users/:/mnt/c/Program:Files/Microsoft:SQL:Server/130/Tools/Binn/:/mnt/c/Program:Files/Microsoft:SQL:Server/Client:SDK/ODBC/170/Tools/Binn/:/mnt/c/Program:Files/PsychoPy3:/mnt/c/Program:Files/PsychoPy3/DLLs:/mnt/c/Users/reyes/AppData/Roaming/Python/Python36/Scripts:/mnt/c/Users/reyes/AppData/Roaming/Python/Python36:/mnt/c/Program:Files/PsychoPy3/Lib/site-packages:/mnt/c/Program:Files/PsychoPy3/Scripts:/mnt/c/Program:Files/NVIDIA:Corporation/NVIDIA:NvDLISR:/mnt/c/Program:Files/Git/cmd:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program:Files/Amazon/AWSCLIV2/:/mnt/c/Users/reyes/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/reyes/AppData/Local/Programs/Microsoft:VS:Code/bin:/mnt/c/Users/reyes/AppData/Roaming/Python/Python36/site-packages:/home/patreyes/abin

R_LIBS = /home/patreyes/R


------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME
top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : found AFNI_demos under $HOME
top history: 22 Oct 2019 [discoraj]: added Cluster Explorer Demo
data dir : found suma_demo under $HOME
top history: NONE FOUND
data dir : found afni_handouts under $HOME
atlas : found TT_N27+tlrc under /home/patreyes/abin

------------------------------ OS specific -------------------------------
which apt-get : /usr/bin/apt-get
apt-get version : apt 2.0.2 (amd64)

have Ubuntu system: ubuntu 20.04 focal
have Ubuntu afni : Precompiled binary linux_ubuntu_16_64: Aug 4 2020

========================= summary, please fix: =========================

  • have python version 3.8.2, but a few programs need 2.7.x

But now, when try ‘afni’ receive just this back (again, even after a few restarts and making sure i do xLaunch first prior):

PatrickDesktop:~> afni
Precompiled binary linux_ubuntu_16_64: Aug 4 2020 (Version AFNI_20.2.10 ‘Aulus Vitellius’)

** Version check disabled: AFNI_VERSION_CHECK forbids
Thanks go to A Martin for much encouragement

Initializing: X11Error: Can’t open display: :0.0
++ AFNI is detached from terminal.

Am unsure what happened between first succesful GUI launch to now, any help appreciated.

Hello all,

Actually, belay this request for help as I seem to have found the issue. Tried to retrace steps between first successful GUI launch and current error, think on big changes I made. Seems that difference between WSL 1 and WSL 2 is the key. After Ubuntu install, converted to WSL 2 later part of install as per Windows’ instructions ( Note that WSL 2 seems to have been released a few months ago (early part of 2020).

I had set distribution version to WSL 2 by running this in Command Prompt, followed by a conversion that took a few minutes

wsl --set-version Ubuntu 2

Seems that after doing so, AFNI GUI would not launch.

But tried conversion back to WSL1 and made sure my default distro was WSL 1 using the following in Command Prompt

wsl --set-version Ubuntu 1
wsl --set-default-version 1

Then restarted computer, ran xLaunch again and attempted ‘afni’ in Ubuntu, met with success.

Thus, seems that so far, best to keep in WSL 1 for Win10 to run AFNI etc.

Hi, Pat-

Thanks for these comments. We are aware that WSL 2 is out there now and that it has changed a lot of things… Sigh.

Daniel bravely undertook the early efforts at documenting installation; we still have some things to work out and decide on (e.g., what is best X launcher now?). It may (= will) take a little time to sort this out, so I agree that WSL 1 is the better way to go for now-- thanks for pointing out how to control/set this aspect.


We are able to get WSL 2 working with AFNI. The X11 display became more complicated with WSL2 because it’s now done over a virtual network between the WSL environment and the native Windows environment. If you did want to try WSL2 again, then you would set the DISPLAY like this in your .bashrc file for the Ubuntu configuration.

export DISPLAY=“$(/sbin/ip route | awk ‘/default/ { print $3 }’):0”

Also the X11 server under Windows needs to be set to allow for these connections. In VcXsrv, you would check the box for “Disable Access Control” and uncheck “Native OpenGL”. MobaXterm is another X11 server that also works as a terminal application. You can set that to work also similarly to change MobaXterm settings and set X11 remote access to full instead of “on-demand”. I expect/hope that the X11 server applications will eventually be a little simpler to use. Microsoft supposedly will integrate X11 at some point too.