Here’s how to set up Python for development on WSL.
Why Python on WSL?
WSL provides access to Linux tools, including programming tools, in a more familiar environment.
The same goes for many pre-written scripts you might find across the web.
There is a native port for Windows, but it tends to work the way Windows does.
This can make it difficult to port apps written in Python for Windows to other systems.
An environment like WSL enforces a more Unixy development style.
Its likely that you have Python installed already, whether thats in Debian/Ubuntu, openSUSE, or Oracle Linux.
While Python is typically included by default on Linux distros, the actual version may differ.
Python 3 is the one thats in active development, but some systems include Python 2 for backward compatibility.
The latter is unmaintained, even for security updates,according to the Python developers.
If you see any Python 2 versions, you have several options.
If the system still has Python 2 installed, it will just be replaced with the Python 2 executable.
This could affect all the scripts on the system.
The way the interpreter works is simple.
Just like the shell, theres a prompt for you to jot down input.
Once you hitEnter, the Python interpreter will evaluate your code and return the output.
This will either be an warning pop-up or the result of some operation.
A good thing to try is the standard code snippet across the development world,printing Hello, world!
Writing Python Scripts in WSL
Writing Python scripts in WSL is also simple.
This is important because Python may be installed in different directories depending on the distribution or operating system.
Its typically installed with many Linux distros, even on WSL.
Calling the interactive interpreter and writing scripts is also easy.