Wiki‎ > ‎

Windows Subsystem for Linux (WSL), Anaconda, Conda, Jupyter

posted Oct 24, 2017, 11:31 AM by Danny Xu   [ updated Jan 29, 2019, 8:32 PM ]
Wow!!! Starting in Windows 10 Anniversary Update, the Windows Subsystem for Linux can invoke native Windows binaries from the Linux console and Linux binaries from a Windows console

1. Powershell Admin
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

2. Download openSUSE 

4. Unzip to C:\User\Administrator\openSUSE-42

5. Powershell Admin

$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + "C:\Users\Administrator\openSUSE-42", "User")

6. Run <distro>.exe    openSUSE-42.exe

7. set up a non-root account/passwd and set root passwd for sudo

To change default user: 

useradd wsl
passwd wsl

Powershell Admin: 

openSUSE-42.exe config --default-user wsl

This python script allows installing and switching ANY Linux distro to WSL in Win10

Switch WSL user accounts:

Setup guide

System location C:\Users\xxx\AppData\Local\Packages\46932SUSE.openSUSELeap42.2_022rs5jcyhyac\LocalState\rootfs

Windows Automatic backup using WSL (cron+rsync)

In openSUSE 42.3 WSL, cron is called cronie and unlike Ubuntu WSL, is not automatically installed.

1) Yast2, install cronie
2) Install and
3) Add them to /etc/crontab
4) Edit autostartcron.vbs script

set ws=wscript.createobject("") "C:\Windows\System32\bash.exe -c 'sudo /usr/sbin/cron -nx pars,load'",0

5) Add the vbs script to Task Scheduler for auto start on system startup

Background Tasks in WSL

openSUSE-42.exe /?

useradd -m new_user
passwd new_user
userdel new_user
rm -rf /home/new_user

With non root users, Windows user can use ssh to login to WSL with their own WSL username and custom home folder

WSL does not support native Linux NFS mount
mount: unknown filesystem type 'nfs'
So need to use services for NFS, see

(In PowerShell)  mount.exe -o anon -o nolock host:/share Z:

This allow read-only mount with anonymous user. To enable write, need to change UID/GID of the anonymous user, not recommended!

Or mount as samba

(This is inside WSL) mount -t drvfs '\\host\share' /mnt/share

Setting OpenSSH in WSL as a Windows service and allow incoming connections at port 22

On OpenSUSE, need to run "ssh-keygen -A" before starting the sshd server

  • Create a text file autostartssh.vbs in Windows containing the following:

    set ws=wscript.createobject("") "C:\Windows\System32\bash.exe -c 'sudo /usr/sbin/sshd -D'",0
    • Double-click on the script. It should start sshd; you should be able to ssh into your Windows machine.
    • Open Windows's Task Scheduler. Add a task that runs autostartssh.vbs on system boot. Use wscript.exe as the command to run and the VBS script location as the parameter.

Setting up right folder/file permission between WSL and Windows is tricky. Create /etc/wsl.conf to enable WSL metadata supports

# Enable extra metadata options by default
enabled = true
# root = /windir/
options = "metadata,umask=22,fmask=11"
mountFsTab = false

System setup

To run 3D program, need to install Mesa, Mesa-libGL1, xwininfo, libXi6, Mesa-demo-x, libGLU1, htop  (real 3D programs don't work!)

After finish installing OpenSUSE 42.3 in WSL, setup MobaXterm
I already had a persistent home dir set up within MobaXterm, so I chose it as the startup folder for launching the WSL shell. The point is that Microsoft doesn't want users to touch any of its WSL files, so even user's home dir in WSL is inaccessible from Windows. Therefore, using a dir outside WSL makes the most sense because data files can be accessed by both Windows and WSL. This is very important.

Download (ver 5.0 had SSLE problems...) from and sudo install to /usr/local

In order to use Firefox or Chrome for Windows, add it to Windows path
  1. Start the System Control Panel applet (Start - Settings - Control Panel - System).
  2. Select the Advanced tab.
  3. Click the Environment Variables button.
  4. Under System Variables, select Path, then click Edit.
vi /mnt/d/MobaXterm/slash/bin/xdg-open  add firefox.exe to the list. xdg-open is a launcher used in Mobaxterm

    if [ x"$BROWSER" = x"" ]; then

Anaconda root env already has jupyter installed, first thing to set up a passwd:  jupyter notebook password

Matplotlib works fine in WSL.

nglview in pytraj and HTMD had issues with Widget Javascripts...  see
Also the version in bioconda was 0.65, Current version on GIT is 1.0b2.
Follow the steps to install the latest nglview to Pytraj, HTMD, and other packages:

conda create -n pytraj python=3.6
source activate pytraj
conda install pytraj -c ambermd --name pytraj
conda install matplotlib --name pytraj
conda install nglview -c bioconda --name pytraj (this installs the 0.65 version)
pip install nglview==1.0b2
jupyter-nbextension enable nglview --py --sys-prefix
jupyter nbextension enable --py --sys-prefix widgetsnbextension # enable ipywidgets since we installed via pip
jupyter notebook

conda create -n htmd python=3.6
conda config --add channels acellera
conda config --add channels psi4
source activate htmd
conda install htmd --name htmd (this installs matplotlib and nglview 0.65 version)
pip install nglview==1.0b2
conda config --remove channels acellera
conda config --remove channels psi4

You will a warning when you use pip to install the lastest nglview:
Installing collected packages: ipywidgets, nglview
  Found existing installation: ipywidgets 5.2.2
    DEPRECATION: Uninstalling a distutils installed project (ipywidgets) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling ipywidgets-5.2.2:
      Successfully uninstalled ipywidgets-5.2.2
  Found existing installation: nglview 0.6.5
    Uninstalling nglview-0.6.5:
      Successfully uninstalled nglview-0.6.5
Successfully installed ipywidgets-7.0.0 nglview-1.0b2

To Test nglview and ipywidgers installation:

import nglview as nv

import ipywidgets

1. Conda installation
conda install -c conda-forge jupyterhub  # installs jupyterhub and proxy
conda install notebook  # needed if running the notebook servers locally

Error: "Failed to find proxy ['configurable-http-proxy']"
For some reason jupyterhub must find configurable-http-proxy in /usr/bin, the default location is /garlic/apps/anaconda3/bin

Fix: cp -s /garlic/apps/anaconda3/bin/configurable-http-proxy /usr/bin/

2. Conda pip installation
pip install jupyterhub In yast2: install nodejs package for npm (location: /usr/bin/npm) pip install notebook # needed if running the notebook servers locally
pip will generate configurable-http-proxy in /usr/bin so there is no problem.

3. sudo jupyterhub 
default on port 8000, can login with server username/passwd, but fail to start server
Error: Unhandled error starting server: [Errno 2] No such file or directory: 'jupyterhub-singleuser'

Fix: generate a default config file, sudo jupyterhub --generate-config

Tell it to use the absolute-path for jupyterhub-singleuser in your config, rather than relying on PATH:
c.Spawner.cmd = '/garlic/apps/anaconda3/bin/jupyterhub-singleuser'

To check path:
sudo -s env PATH=.... which jupyterhub /garlic/apps/anaconda3/bin/jupyterhub which jupyterhub-singleuser /garlic/apps/anaconda3/bin/jupyterhub-singleuser

It is recommended to store configuration files in the standard UNIX filesystem location, i.e. /etc/jupyterhub.

Start the server! jupyterhub -f /etc/jupyterhub/

To have jupyterhub access a new env, create a new kernel, see

ipython kernel install --user --name pytraj

Go back to the Jupyterhub dashboard, reload the page, now you should have another option in the New menu that says pytraj.

In order to use your new kernel with an existing notebook, click on the notebook file in the dashboard, it will launch with the default kernel, then you can change kernel from the top menu Kernel > Change kernel.

Having issues with nglview on garlic jupyterhub... not showing structure, no error message:

For system-wide:
sudo jupyter-nbextension enable nglview --py --sys-prefix
sudo jupyter nbextension enable --py --sys-prefix widgetsnbextension

For a user:
jupyter nbextension enable --py --user widgetsnbextension
jupyter-nbextension enable nglview --py --user