The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Follow publication

The Founder’s Guide:

How to Install Software From Source Code in WSL2

David Littlefield
The Startup
Published in
6 min readNov 9, 2020
Image by Markus Spiske

The expanded version of this article explains each step with enough detail to learn what’s happening.

Download Python:

  1. Visit the official website: [3.5] [3.6] [3.7] [3.8]
  2. Scroll to the “Files” section
  3. Download the “Gzipped Source Tarball” file

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Right-click “Windows PowerShell”
  4. Click “Run as Administrator”

Open the Downloads Directory:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd $HOME\Downloads

Open WSL2:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
wsl

Unzip the Python File:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
sudo tar --extract --verbose --file Python-3.5.9.tgz
Python 3.6:
sudo tar --extract --verbose --file Python-3.6.12.tgz
Python 3.7:
sudo tar --extract --verbose --file Python-3.7.9.tgz
Python 3.8:
sudo tar --extract --verbose --file Python-3.8.5.tgz

Open the Python Directory:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
cd Python-3.5.9
Python 3.6:
cd Python-3.6.12
Python 3.7:
cd Python-3.7.9
Python 3.8:
cd Python-3.8.5

Update the Package Information:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get update

Upgrade the Packages:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get upgrade

Install the Python Dependencies:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get install libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev tk-dev libgdbm-dev lzma lzma-dev tcl-dev tk-dev

Install CheckInstall:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt-get install checkinstall

Run the Configure File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo ./configure

Run the MakeFile:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo make

Run CheckInstall:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Enter “Yes” to create the package documentation
  5. Press “Enter” to continue with the default summary
sudo checkinstall

Change the Package Name:

  1. Enter “2” to change the package name
  2. Press “Enter”
  3. Find the Python version from below these instructions
  4. Copy the provided command
  5. Paste the command into PowerShell
  6. Press “Enter”
Python 3.5:
python35
Python 3.6:
python36
Python 3.7:
python37
Python 3.8:
python38

Complete the Installation:

  1. Press “Enter” to continue with the current package details
  2. Enter “No” to continue without listing the items
  3. Enter “Yes” to exclude the items from the package
  4. Enter “Yes” to view the log file
  5. Press “Escape” to enter the command mode
  6. Type “:wq” to save without exiting and quit
  7. Press “Enter”

Add the Python Alias:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.5 20
Python 3.6:
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.6 30
Python 3.7:
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.7 40
Python 3.8:
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.8 50

Set the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Enter a selection number
  5. Press “Enter”
sudo update-alternatives --config python

Open the Bash Configuration File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad //wsl$/Ubuntu-18.04$HOME/.bashrc

Add the Sudo Alias:

  1. Scroll to the bottom of the script
  2. Copy the command from below these instructions
  3. Paste the command into Notepad
# User alias definitions
alias sudo="sudo "

Add the Pip Alias:

  1. Copy the command from below these instructions
  2. Paste the command into Notepad
  3. Click the “File” menu
  4. Click “Save”
alias pip="pip3"

Restart Bash:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
exec bash

Add the Pip Program:

  1. Find the Python version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
sudo update-alternatives --install /usr/local/bin/pip3 pip3 /usr/local/bin/pip3.5 20 --force
Python 3.6:
sudo update-alternatives --install /usr/local/bin/pip3 pip3 /usr/local/bin/pip3.6 30 --force
Python 3.7:
sudo update-alternatives --install /usr/local/bin/pip3 pip3 /usr/local/bin/pip3.7 40 --force
Python 3.8:
sudo update-alternatives --install /usr/local/bin/pip3 pip3 /usr/local/bin/pip3.8 50 --force

Set the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Enter a selection number
  5. Press “Enter”
sudo update-alternatives --config pip3

Next Steps:

This article is part of a mini-series that helps readers set up everything they need to start using WSL2 for artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots that help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots that help readers process what’s happening.

01. Install Windows Subsystem for Linux 2 (WSL2)
02. Install the NVIDIA CUDA Driver and Toolkit in WSL2
03. Install Software From Source Code in WSL2
04. Install the Jupyter Notebook Home and Public Server in WSL2
05. Install Virtual Environments in Jupyter Notebook in WSL2
06. Install Programs With a Graphical User Interface in WSL2
07. Install Ubuntu Desktop With a Graphical User Interface in WSL2

Hopefully, this article helped everyone get the prize. If you want to help out then hold the “👋” and click “Follow” to get more content. Thanks for reading!

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

David Littlefield
David Littlefield

Written by David Littlefield

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning

No responses yet

Write a response