So lets create a development environment based on Linux inside of Microsoft Windows 10. We will be using WSL2 (Windows Subsystem for Linux) version 2.
As Linus Torvalds once said "It is best to develop on the platform you are deploying to." Since our applications will be deployed on a Linux server it would be the best option to develop on a GNU/Linux operating system.
Yet why would we want to have Linux running inside of a Windows operating system. Well unfortunately, Windows has a number of benefits as a Desktop operating system over Linux. Although I use a native setup of Linux on a daily basis, Windows has the following advantages:
- Dynamically expanding swap
- Better battery life on laptops
- Commercial Software support
So let's break this down to understand what all of this means and how it is beneficial.
Swap is a file or partition on your SSD/HDD that is used to swap memory from RAM to disk when your RAM is approaching full capacity. This allows for applications to keep running even if you use more memory than you have in physical RAM.
Microsoft Windows and macOS both offer dynamically expanding swap. Which has no fixed size so it can grow or shrink as needed.
Linux and Unix based operating systems use a fixed swap allocation. This space cannot be dynamically resized, it is a fixed space and cannot grow or shrink according to your needs. The problem with this is that if you run out of swap space your OS will become extremely sluggish.
It has been proven that battery life is just better on Windows due to the optimization made by Microsoft and hardware vendors on Windows. Although this is being improved and is getting better on Linux, Windows still excels in this area.
As we all know most commercial software is more available to Windows and macOS operating systems. Specifically with media based software such as video editing, audio production and gaming. Yet this is begin improved on Linux, it still does not offer some industry leading software that are used by professionals.
Step 1. Run PowerShell as administrator
Step 2. Enable WSL by entering the following command in PowerShell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 3. Enable Virtual Machine Platform by entering the following command in PowerShell (You will be prompted to restart Windows, if not please do restart Windows after this step)
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
Step 1. Download the WSL2 Kernal update from the following link: WSL2 Kernal
Step 2. Set WSL version 2 as your default WSL version by entering the following command in PowerShell
wsl --set-default-version 2
Step 1. Open the Microsoft Store and search for
Step 2. Pick a Linux distro of your choice to install for example
Ubuntu and click
After the distro is installed it will open a window to configure your username and password.
This will be used to display all of our Linux GUI apps inside of Windows.
Step 1. Download and install VcXsrv. VcXsrv Download Link
Step 2. Configure VcXsrv
- Use all default settings and click next until you reach the
Extra settingssection where you will select all options
Save configurationand save it to the desktop so you can use it to start VcXsrv again which you will need to do every time you restart or logout of Windows
Step 1. Update your Ubuntu Linux distro by entering the following command in the Ubuntu terminal
sudo apt update sudo apt upgrade
Step 2. Set the display server by entering the following command in the Ubuntu terminal
This will show you your nameserver IP, replace the
xxx.xx.xx.x with the IP retrieved from the above command and enter the following in your Ubuntu terminal
Step 3. Install and run Firefox
Lets see our gui apps in action by installing and running Firefox entering the following in your Ubuntu terminal
sudo apt install firefox firefox
Congratulations, Firefox should be running now! This browser will come in handy for downloading anything we want to run inside of WSl2.
Step 4. Install and run PyCharm CE
- Download PyCharm by opening the following link inside of the Firefox browser you have just opened from within Ubuntu (WSL2).
- Extract the archive which you should find in your home downloads folder inside your Ubuntu WSL terminal under
~/Downloads/by entering the following command and replace
file.tar.gzwith the filename you have downloaded
tar xvzf file.tar.gz
- Run PyCharm from within the
cd pycharm-community/bin ./pycharm.sh
Step 5. Installing pip and miniconda
- We can install pip for Python3 using the following command
sudo apt install python3-pip
- Install miniconda by downloading the installation script from the following link and make sure you open this link from within the firefox browser that is running inside of WSL2
- Once downloaded you can start the installation by going to your Download directory in WSL2 and executing the script using the following command
Step 6. Install Docker Desktop for Windows
- Download Docker Desktop for Windows from the following link
- After installation you will be prompted to logout of Windows
- Once you login to Windows again and docker desktop for Windows is running, you can open Ubuntu WSL2 terminal and run the following commands to make sure that docker is running inside of WSL2:
docker -v docker-compose -v
Congratulations you now have docker running in your WSL2 instance.
You can install more tools inside of WSL2 as you would with any Linux distro. This setup should get you going for Python development.