LEARN PYTHON: ENVIRONMENT

Writing a book is hard… no really, it is really, really hard. What makes it even harder is trying to write a book on a blogging page. Nevertheless, it needs to get done, and I want to get my information out there as fast as possible. This chapter is designed to be more of an introduction and “setup” of your development environment. Prior to that I wrote the first chapters without this, and I realize many of you who may be reading might not have such an easy time setting up your development environments.

Terminals

I’ll be covering all three operating systems, windows, linux, and macOS. Each one is different but they have their similarities, the most recent example being Windows with its Windows Subsystem Linux 2 (WSL 2); Which is an integrated Linux kernel and gives you the power of Linux within Windows. Gone are the days of dual booting a Windows and Linux machine.

Getting Started

Windows

  • Windows 10/11 pro or home
  • Ubuntu 18.04 or 20.04 (Windows Store)
  • Windows Terminal
  • ZSH
  • Oh-my-zsh
  • Python3, Python-pip3

I assume you’re already running at least Windows 10 so we can start installing WSL2. First lets start by downloading Windows Terminal (a special terminal recently created by Microsoft developers to make it easier to use WSL and other Command Prompts in Windows)

Download the Windows Terminal application here and install it. Once installed we can get started on installing WSL. The most convenient part of this process is Windows Terminal’s ability to switch between Powershell, Command Prompt, and Linux Shell. What you want to do here is to open up a Windows Powershell and run the command, wsl --install this will begin the installation of WSL.

After doing so, you can type wsl and press enter to login to WSL2. After that you should have Ubuntu installed and we can begin to use the new shell. Once completed, go to the settings page and configure your Ubuntu-20.04 to look similar, the important part is to have Command line be wsl.exe -d Ubuntu-18.04 or wsl.exe -d Ubuntu-20.04 this by default will always open up the Linux terminal without you needing to mess around every time you open windows.

ZSH

Once inside of your ubuntu terminal, you will want to run sudo apt-get update && sudo apt-get install zsh this will install zsh, you can skip any configuration but if you need to, read up on the configuration to get the hang of it. You are only configuring what your prompt will look like.

OH MY ZSH

Oh My ZSH is an enhanced version of ZSH, so it uses the same configuration schema and allows you to further the terminals customization, that and the fact that it is loaded with all kinds of goodies and powerful functions to make your experience better. Once you have completely installed ZSH, you can run the following script to install oh-my-zsh:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

This will have you configure in a similar way that ZSH did, once it is completely configured you will end up with a beautiful prompt.

NERDFONTS

Now for the goodies, since Windows doesn’t have any way to visualize funky icons on a terminal screen, we need to install some specially patched and formatted fonts. We call these “Nerd Fonts”. Visit https://github.com/ryanoasis/nerd-fonts or if you want the font I am using, download this font and install it. Once installed, go back to Windows Terminal settings -> Defaults -> Ubuntu -> Appearance, then update the font face to be the newly installed font.

Themes

Finally, there are a few things that can change here, your color scheme, and the way your prompts look. You should always remember that your ZSH configuration file, or an rc file lives in your home directory: ~/.zshrc this file is responsible for almost all customizations you will need in your terminal, including any exported variables we talked about in Chapter One. As well as the theme you will be using.

With Windows Terminal, your main color theme is controlled in your Settings -> Defaults -> Ubuntu -> Appearance. You can download windows terminal themes here. You copy and paste the JSON data into the JSON file in the screenshot displayed above, then save that file and select the Color Scheme also listed in the screenshot above.

I know its a little confusing but you will get the hang of it.

Linux

Linux (Ubuntu) installation works the same way, using the apt-get update, and apt-get upgrade commands, and Gogh. Honestly, if you need help with this, feel free to reach out and I will further expand on the installation procedure.

macOS

macOS is similar to Windows except you will be downloading iTerm2 and using as a terminal and Gogh for your color scheme (super convenient). You will also use Brew, ZSH and oh-my-zsh. Gogh can be found here

Some of these setups take some practice to finish off getting used to it. So it will take sometime to do this properly, after you have completed it one or two times, you will start to get the hang of it and your terminal will become a masterpiece for ease of use.