The provided content is a comprehensive guide for beginners on setting up Python development on Windows 10 using the Windows Subsystem for Linux (WSL) with Ubuntu, and includes instructions on installing WSL2, Ubuntu, Windows Terminal, pyenv, and recommendations for Python tutorials and editors.
Abstract
The article "A Beginner’s Guide to Python Development on Windows 10" offers a detailed walkthrough for novice developers to set up a Python development environment on Windows 10 by leveraging the Windows Subsystem for Linux (WSL). It emphasizes the benefits of using Linux, particularly Ubuntu, through WSL2 to overcome the suboptimal Python support on native Windows. The guide covers the installation of WSL2, Ubuntu, and the Windows Terminal, as well as the configuration of the terminal with Powerline fonts for a more aesthetically pleasing interface. It also explains how to install pyenv for Python version management and recommends installing Python version 3.8.6. The article concludes with editor suggestions, such as Visual Studio Code, Sublime Text, and PyCharm Professional, and advises on navigating between Windows and Linux file systems. For learning resources, it points to the official Python tutorial and a jumpstart course by building 10 apps, acknowledging the help received from a colleague in the process.
Opinions
The author suggests that using Linux through WSL2 is preferable for Python development on Windows due to the prevalent use of Linux among Python developers and the platform-specific code in some Python packages.
The article implies a lack of comprehensive Python support on Windows by highlighting the ease of following Linux-based tutorials when using WSL2.
The recommendation of pyenv indicates the author's preference for flexibility in managing multiple Python versions.
The author expresses a personal preference for Sublime Text as an editor due to its lightweight and distraction-free environment, while also acknowledging other popular editors like Visual Studio Code and PyCharm Professional.
The mention of the official Python tutorial and the Python Jumpstart course suggests that the author values structured learning for beginners, regardless of prior programming experience.
The author expresses gratitude towards a colleague, Marcus Windmark, for assisting with Python setup on Windows, indicating a collaborative approach to learning and development.
A Beginner’s Guide to Python Development on Windows 10
Using Linux 😄
Image by Martin Thoma
The Python programming language is used for web development, data analysis, machine learning, statistics, web scraping, and so much more. There are tons of tutorials which, ironically, makes it pretty hard to recommend one. However, there is also a lack of support for Windows.
Let’s get the very first step done: Install it on Windows. You could use Python through Anaconda, but in this article, we will use it on Windows with WSL. This prepares you to go with one of the many tutorials to start your Python career.
What is WSL?
The Windows Subsystem for Linux (WSL) is a compatibility layer that allows you to run Linux binaries on Windows. WSL2 uses the Linux Kernel (source). On top of WSL, you can run the Linux-flavor “Ubuntu”. Such a kind of “flavor” is called a distribution. There are many other distributions, but Ubuntu is by far the most wide-spread option.
This is pretty awesome because most Python developers use Linux. This means many tutorials assume that you have access to Linux programs and some Python packages contain code that is platform-specific. The Python community is increasingly becoming aware of the issue that Windows support is sub-optimal, but for now, using (something similar to) Linux is just the easier path.
Install WSL2 and Ubuntu
I recommend to follow the official Microsoft guide:
Launch a terminal and navigate to the settings. It’s this small downwards pointing “arrow”:
Click on “Settings”. The screenshot was taken by Martin Thoma
You should see a JSON file which you can change to fit your taste. I have the following:
Install pyenv
pyenv lets you run any Python runtime you like. To install it, run the following commands. Lines that begin with $ indicate that you should enter what follows. Copy everything except the $ until the next $
Close all terminals and open one again. Now the command pyenv should show you the help:
Screenshot by Martin Thoma
Most importantly the command pyenv install --list which shows you all the different Python versions you can install. I recommend installing 3.8.6 as of October 2020.
There are two beginner-friendly, gratis, wide-spread editor options: Visual Studio Code and Sublime Text. A lot of people also like PyCharm Professional and some hackers like vim / Emacs. Personally, I do most of my work in Sublime Text. I like that it is super lightweight and doesn’t have a lot of distracting information.
I highly recommend navigating within Windows to \\wsl$\Ubuntu\home . So you are within Windows on the Linux part.
You can also go to /mnt/c/Users within Ubuntu, but this way things become crazy slow.
How can I continue?
If you want an introduction to Python from the beginning, try the official Python tutorial. Although I already had programming experience when I started with Python, I went through this to make sure I know the basics.