Python/Django development on Windows with WSL

Microsoft offers the WSL feature (Windows Subsystem for Linux) for a couple of years now (since 2016 to be precise). This can be perfectly used for setting up your local development environment. It won’t take much longer than Windows native and comes with more comfort especially when you start to integrate other dependencies like MySQL. Setting up MySQL+Python on Windows is really everything else then nice.

  1. Enable WSL in Windows Features (it was already enabled on my computer)
  2. Install Ubuntu (or other Linux distribution) from the Windows Store
  3. Open Ubuntu Command Line and enter your new credentials
  4. sudo apt-get update – this was necessary on my WSL-Ubuntu for installing any packages. Apparently, the packages repos were not initialized when installing Ubuntu
  5. cd /mnt/c/User/{YourUsers}/…. by default the Windows filesystem is available under /mnt/c
  6. sudo apt-get install python3-pip
  7. pip3 install virtualenv
  8. virtualenv venv
  9. source venv/bin/activate
  10. pip3 install django
  11. django-admin startproject app .
  12. python3 manage.py runserver
  13. Windows Chrome: https://127.0.0.1:8000 port forwarding is already enabled by default from WSL

As you can see: the steps were pure Linux Command Line on Window. Moreover, there was no further configuration or anything needed. It just worked with pre-configured mounting into WSL and port-forwarding.