A Beginner’s Guide to Python Development on Windows 10

Using Linux 😄

Martin Thoma
Oct 20 · 4 min read
Image for post
Image for post
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 and Configure Windows Terminal

When Ubuntu is installed, install Windows Terminal:

Download and install all 4 “DejaVu Sans Mono Powerline” fonts.

Launch a terminal and navigate to the settings. It’s this small downwards pointing “arrow”:

Image for post
Image for post
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 $

$ sudo apt-get install git
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
# Copy the next two lines, except the first $
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
# Copy the next two lines, except the first $
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
# Install the build dependencies
$ sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Close all terminals and open one again. Now the command pyenv should show you the help:

Image for post
Image for post
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.

$ pyenv install 3.8.6
Downloading Python-3.8.6.tar.xz...
-> https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz
Installing Python-3.8.6...
Installed Python-3.8.6 to /home/math/.pyenv/versions/3.8.6

After that, you can use it globally:

$ pyenv global 3.8.6$ python --version
Python 3.8.6
$ pip --version
pip 20.2.1 from /home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)

Editor

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.

If you have some programming background, there is also the Python Jumpstart by building 10 apps. I haven’t tried it, but I love the talk Python podcast.

Acknowledgment

A big THANK YOU to my colleague Marcus Windmark who helped me to get started with Python on Windows 🤗

Python In Plain English

Go deeper with the language powering everything.

Martin Thoma

Written by

I’m a Software Engineer with focus on Data Science, Machine Learning. I have over 10 years of experience with Python. https://www.linkedin.com/in/martin-thoma/

Python In Plain English

Go deeper with the language powering everything.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store