{"id":700,"date":"2022-12-02T10:04:30","date_gmt":"2022-12-02T10:04:30","guid":{"rendered":"https:\/\/tbekk.com\/devstream\/?p=700"},"modified":"2022-12-02T10:06:29","modified_gmt":"2022-12-02T10:06:29","slug":"configuring-your-windows-development-machine-for-data-science","status":"publish","type":"post","link":"https:\/\/tbekk.com\/devstream\/2022\/12\/02\/configuring-your-windows-development-machine-for-data-science\/","title":{"rendered":"Configuring your Windows development machine for data science"},"content":{"rendered":"\n<p><em>Interested in topics such as Data Science, Machine Learning, Data Analysis, etc.?  Working on windows? Here&#8217;s an article explaininng how you can setup your box for such tasks.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\">Introduction<\/h2>\n\n\n\n<p>In this post, I\u2019ll show you how you can set up your Windows development machine for data science projects. I assume that you have Windows 11 installed on your machine, and no other applications or packages related to data science. I like to configure my machine using VS Code, WSL, Ubuntu, Zsh, Miniconda, and Git, so that\u2019s what I\u2019ll be showing you in this post. If you\u2019re new to data science, I recommend that you follow the same technology choices \u2014 with time, you\u2019ll develop your own preferences. If you\u2019re a seasoned data scientist, you can follow the sections that match your preferences and complement them with your own favorite technologies.<\/p>\n\n\n\n<p>Let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"vs-code\">VS Code<\/h2>\n\n\n\n<p>VS Code is my editor of choice. It\u2019s great for so many reasons, but especially because it integrates well with the Windows Subsystem for Linux (WSL for short). You can download and install the Windows version of VS Code from&nbsp;<a href=\"https:\/\/code.visualstudio.com\/Download\" target=\"_blank\" rel=\"noreferrer noopener\">this page<\/a>. Once you\u2019ve got VS Code installed and running, choose Extensions in the left navigation pane, search for the \u201cWSL\u201d extension from Microsoft and install it:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/11-vscode-wsl.png\" alt=\"Screenshot of VS Code WSL extension.\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"windows-subsystem-for-linux\">Windows Subsystem for Linux<\/h2>\n\n\n\n<p>The next step in our setup is to install&nbsp;<a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/wsl\/about\" target=\"_blank\" rel=\"noreferrer noopener\">WSL<\/a>, which enables us to use Linux directly on a Windows machine, without the overhead of a traditional virtual machine or dual-boot setup. As a former Linux user, WSL has been a game-changer for me on Windows. I\u2019ve been using WSL since its early beta days, and I love how much easier it is to install now, and how stable it is.<\/p>\n\n\n\n<p>In order to get WSL set up on your machine, you need to enable the \u201cVirtual Machine Platform\u201d feature on Windows. You can do that by typing \u201cTurn Windows features on or off\u201d in the taskbar\u2019s search field:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/1-features.png\" alt=\"Screenshot of searching for &quot;Turn Windows featurs on or off&quot;.\"\/><\/figure>\n\n\n\n<p>Then check the checkbox near \u201cVirtual Machine Platform\u201d:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/2-virtual.png\" alt=\"Screenshot of the &quot;Virtual Machine Platform&quot; feature.\"\/><\/figure>\n\n\n\n<p>Next, open the Microsoft Store app, search for \u201cWindows Subsystem for Linux\u201d by \u201cMicrosoft Corporation,\u201d and install it:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/3-wsl.png\" alt=\"Screenshot of the &quot;Windows Subsystem for Linux&quot; app in the Microsoft store.\"\/><\/figure>\n\n\n\n<p>If you run into issues or need more detailed steps, I recommend that you read&nbsp;<a href=\"https:\/\/ubuntu.com\/tutorials\/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview\" target=\"_blank\" rel=\"noreferrer noopener\">this tutorial<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ubuntu\">Ubuntu<\/h2>\n\n\n\n<p>You can also use the Microsoft Store to install whichever Linux distribution you want to use with WSL. I generally use Ubuntu, so that\u2019s what I\u2019ll show here. If you search for \u201cUbuntu\u201d in the Microsoft store, you might see something similar to this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/4-ubuntu.png\" alt=\"Screenshot of searching for &quot;Ubuntu&quot; in the Microsoft store.\"\/><\/figure>\n\n\n\n<p>You can pick a specific version of Ubuntu, but I prefer to choose the option without a version, which automatically upgrades to the latest stable version.<\/p>\n\n\n\n<p>Once Ubuntu finishes installing, open the app. This launches a terminal window, where you\u2019ll be prompted to supply a username and password for the newly created Linux administrator account. These are the credentials you\u2019ll need to enter whenever you execute a command with \u201csudo\u201d to elevate privileges, so choose wisely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"zsh\">Zsh<\/h2>\n\n\n\n<p>The&nbsp;<a href=\"https:\/\/www.zsh.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Zsh<\/a>&nbsp;shell is an alternative to the default&nbsp;<a href=\"https:\/\/www.gnu.org\/software\/bash\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bash<\/a>&nbsp;shell. If you\u2019re happy with Bash and want to keep your machine setup simple, you can skip this section. I like to use Zsh because it supports everything that Bash supports, with several useful additional features: it has much smarter support for tab auto-completion, it includes many commonly used aliases, and it shares command history across active shells.<\/p>\n\n\n\n<p>If you don\u2019t already have an Ubuntu terminal window open, search for and start the \u201cTerminal\u201d app. Click on the downward-pointing chevron in the title bar and select the \u201cUbuntu\u201d option to open a new tab that\u2019s running Ubuntu. To install Zsh, type the following command and enter your administrator password if you\u2019re asked for credentials:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install zsh\n<\/code><\/pre>\n\n\n\n<p>The first time you run Zsh, you will be asked how you want to create your&nbsp;<code>.zshrc<\/code>&nbsp;configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>zsh\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/10-zshrc.png\" alt=\"Screenshot of .zshrc configuration.\"\/><\/figure>\n\n\n\n<p>I generally select option&nbsp;<code>0<\/code>, which creates the&nbsp;<code>.zshrc<\/code>&nbsp;file with just a comment. We\u2019ll customize this file in a later step.<\/p>\n\n\n\n<p>Next, I like to install&nbsp;<a href=\"https:\/\/ohmyz.sh\/#install\" target=\"_blank\" rel=\"noreferrer noopener\">Oh My Zsh<\/a>, which is an open source, community-driven framework for managing your Zsh configuration. It provides you with a wide range of plugins and themes, and it has a vibrant community of users. It\u2019s my framework of choice for managing Zsh. Here\u2019s how we can install it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sh -c \"$(curl -fsSL https:\/\/raw.github.com\/ohmyzsh\/ohmyzsh\/master\/tools\/install.sh)\"\n<\/code><\/pre>\n\n\n\n<p>We\u2019ll configure Oh My Zsh later in this post, by adding a few plugins to the&nbsp;<code>.zshrc<\/code>&nbsp;configuration file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"miniconda\">Miniconda<\/h2>\n\n\n\n<p>When coding with Python, it\u2019s convenient to have a tool that manages our packages and environments for each project. It\u2019s common for different projects to use different versions of the same packages, which can make switching from one project to the next unwieldy. That\u2019s where tools like&nbsp;<a href=\"https:\/\/docs.conda.io\/en\/latest\/miniconda.html\" target=\"_blank\" rel=\"noreferrer noopener\">Miniconda<\/a>&nbsp;come in: they enable us to switch from one set of dependencies to another with a single command. There are many other package managers with similar goals, such as&nbsp;<a href=\"https:\/\/docs.conda.io\/projects\/conda\/en\/stable\/\" target=\"_blank\" rel=\"noreferrer noopener\">Conda<\/a>,&nbsp;<a href=\"https:\/\/pypi.org\/project\/pip\/\" target=\"_blank\" rel=\"noreferrer noopener\">pip<\/a>, and&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/venv.html\" target=\"_blank\" rel=\"noreferrer noopener\">venv<\/a>. I prefer Miniconda to Conda because I don\u2019t need most of the extra functionality that comes with Conda, such as support for programming languages other than Python. And I like both Miniconda and Conda better than other package managers I\u2019ve used because they help me manage the version of Python itself, in addition to all other packages that my project needs.<\/p>\n\n\n\n<p>You can find the installation links for Miniconda&nbsp;<a href=\"https:\/\/docs.conda.io\/en\/latest\/miniconda.html\" target=\"_blank\" rel=\"noreferrer noopener\">on this page<\/a>. For a WSL setup, you\u2019ll need to choose the \u201cMiniconda3 Linux 64-bit\u201d version. Clicking on the link will download a file with extension&nbsp;<code>.sh<\/code>. You can install it by copying it to a suitable location within Ubuntu, and then running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sh .\/Miniconda3-latest-Linux-x86_64.sh\n<\/code><\/pre>\n\n\n\n<p>You need the Linux version, rather than the Windows version, because you\u2019ll be doing your package management from within WSL, not Windows!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"git\">Git<\/h2>\n\n\n\n<p>I use Git (in conjunction with GitHub) for source code management \u2014 who doesn\u2019t, these days? I like to be able to run Git commands both from within VS Code (which runs on Windows) and from the terminal (which is running Linux). I prefer VS Code\u2019s user interface for common operations like creating branches, committing and pushing changes, and pulling the latest code; but I still want access to Git in my Linux terminal for more advanced operations. Therefore, I configure Git twice \u2014 once for Windows and once for Linux.<\/p>\n\n\n\n<p>Thankfully the steps you need to follow on Windows and Linux are pretty much the same, the only difference being that on Windows you execute them using the Git Bash app, and on Linux you execute them within your terminal. The GitHub web site provides excellent documentation on how to set up Git, so I\u2019ll just link to the appropriate pages. Note that these pages contain steps for both Windows and Linux, so be sure to follow the instructions on each of those tabs:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Step 1:&nbsp;<a href=\"https:\/\/docs.github.com\/en\/authentication\/connecting-to-github-with-ssh\/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent\" target=\"_blank\" rel=\"noreferrer noopener\">Generate a new SSH key and add it to the ssh-agent<\/a><\/li><li>Step 2:&nbsp;<a href=\"https:\/\/docs.github.com\/en\/authentication\/connecting-to-github-with-ssh\/adding-a-new-ssh-key-to-your-github-account\" target=\"_blank\" rel=\"noreferrer noopener\">Add a new SSH key to your GitHub account<\/a><\/li><li>Step 3:&nbsp;<a href=\"https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/setting-your-username-in-git\" target=\"_blank\" rel=\"noreferrer noopener\">Configure your username<\/a><\/li><li>Step 4:&nbsp;<a href=\"https:\/\/docs.github.com\/en\/account-and-profile\/setting-up-and-managing-your-personal-account-on-github\/managing-email-preferences\/setting-your-commit-email-address#setting-your-commit-email-address-in-git\" target=\"_blank\" rel=\"noreferrer noopener\">Configure your email<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"terminal\">Terminal<\/h2>\n\n\n\n<p>For the most part, there are no right or wrong decisions in terminal configuration \u2014 it all comes down to personal choice. I\u2019ve settled on the look shown below, which I\u2019ll explain how to configure in this section:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/8-terminal.png\" alt=\"Screenshot of my terminal.\"\/><\/figure>\n\n\n\n<p>The Windows \u201cTerminal\u201d app allows you to open multiple terminal tabs, using any number of different profiles. You can see all your profiles by clicking on the downward-pointing chevron in the title bar. For example, I have \u201cWindows PowerShell,\u201d \u201cCommand Prompt,\u201d \u201cAzure Cloud Shell,\u201d and \u201cUbuntu\u201d:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/5-profiles.png\" alt=\"Screenshot of the terminal profiles on my machine.\"\/><\/figure>\n\n\n\n<p>For the purpose of data science, we\u2019ll be using the \u201cUbuntu\u201d profile, so that\u2019s what I\u2019ll focus on in this section. We\u2019ll start by configuring the settings of the Terminal app (such as the default profile), and then we\u2019ll adjust the Linux settings (such as the Oh My Zsh plugins).<\/p>\n\n\n\n<p>You can change your Terminal settings by clicking on the downward-pointing chevron and selecting \u201cSettings,\u201d which opens the Startup settings by default. I changed my \u201cdefault profile\u201d setting to \u201cUbuntu,\u201d since that\u2019s the profile I want to use when I create a new tab in the app.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/6-startup.png\" alt=\"Screenshot of the terminal's startup settings.\"\/><\/figure>\n\n\n\n<p>Next let\u2019s configure the appearance of our terminal window. The Terminal app comes pre-packaged with several different color schemes, and you could simply select one that works for you. Or, if you\u2019re like me, you\u2019ll want to fully configure your own. To do that, click on \u201cOpen JSON file\u201d at the bottom left of the window, and add a new color scheme to the \u201cschemes\u201d section. Here\u2019s the one I use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"background\": \"#002B36\",\n    \"black\": \"#002B36\",\n    \"blue\": \"#268BD2\",\n    \"brightBlack\": \"#657B83\",\n    \"brightBlue\": \"#839496\",\n    \"brightCyan\": \"#D33682\",\n    \"brightGreen\": \"#B58900\",\n    \"brightPurple\": \"#EEE8D5\",\n    \"brightRed\": \"#CB4B16\",\n    \"brightWhite\": \"#FDF6E3\",\n    \"brightYellow\": \"#586E75\",\n    \"cursorColor\": \"#FFFFFF\",\n    \"cyan\": \"#2AA198\",\n    \"foreground\": \"#96A1A1\",\n    \"green\": \"#859900\",\n    \"name\": \"wsl\",\n    \"purple\": \"#6C71C4\",\n    \"red\": \"#DC322F\",\n    \"selectionBackground\": \"#FFFFFF\",\n    \"white\": \"#93A1A1\",\n    \"yellow\": \"#B58900\"\n}\n<\/code><\/pre>\n\n\n\n<p>Notice that the \u201cname\u201d of this color scheme is set to \u201cwsl.\u201d To use it, click on your default Ubuntu profile, scroll down to \u201cAdditional settings,\u201d click on \u201cAppearance,\u201d and select \u201cwsl\u201d from the drop-down menu.<\/p>\n\n\n\n<p>I also like to use the \u201cFira code\u201d font, which doesn\u2019t come pre-installed with Windows. To install it, I download it from&nbsp;<a href=\"https:\/\/fonts.google.com\/specimen\/Fira+Code\" target=\"_blank\" rel=\"noreferrer noopener\">this page<\/a>, select all files in the \u201cstatic\u201d directory, right-click, and select \u201cInstall.\u201d I can then use it by setting the \u201cFont face\u201d to \u201cFira Code\u201d in the \u201cAppearance\u201d settings:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/bea.stollnitz.com\/images\/configure-dev-machine\/9-appearance.png\" alt=\"Screenshot of the Appearance settings.\"\/><\/figure>\n\n\n\n<p>To configure the Linux settings, I clone my&nbsp;<a href=\"https:\/\/github.com\/bstollnitz\/dotfiles\" target=\"_blank\" rel=\"noreferrer noopener\">dotfiles<\/a>&nbsp;repo and run its installation script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone git@github.com:bstollnitz\/dotfiles.git\ncd dotfiles\n.\/install.sh\n<\/code><\/pre>\n\n\n\n<p>My dotfiles Git repo contains all the files I need to configure my Linux terminal, and an&nbsp;<code>install.sh<\/code>&nbsp;main executable shell file that kicks off the process. The commands in this repo set up Zsh, Oh My Zsh, and the Spaceship custom theme for the prompt. You can read about the contents of these scripts in detail in my blog post about&nbsp;<a href=\"https:\/\/bea.stollnitz.com\/blog\/codespaces-terminal\/\" target=\"_blank\" rel=\"noreferrer noopener\">configuring my terminal for Codespaces<\/a>. That blog is written with&nbsp;<a href=\"https:\/\/docs.github.com\/en\/codespaces\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Codespaces<\/a>&nbsp;in mind because automating the Linux terminal configuration is particularly useful in that context. Every time I create a new Codespace (which if often!), I automatically get a nicely configured Linux terminal to work with. But the same dotfiles are useful when setting up a new machine, or in any other scenario where you need a familiar terminal configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this post, we started with a machine containing nothing but Windows 11, and ended up with a machine that\u2019s ready to tackle data science projects. We installed VS Code, WSL, Ubuntu, Zsh, and Miniconda, and then proceeded to configure Git and our terminal.<\/p>\n\n\n\n<p>You may be wondering why I didn\u2019t talk about installing Python and popular data science packages like PyTorch, Numpy, and Pandas. That\u2019s because I may want to configure those dependencies differently for each project, as I explain in my post about&nbsp;<a href=\"https:\/\/bea.stollnitz.com\/blog\/vscode-ml-project\/\" target=\"_blank\" rel=\"noreferrer noopener\">setting up machine learning projects<\/a>.<\/p>\n\n\n\n<p>Hopefully this article has helped you to configure your Windows machine, and you\u2019re now well on your way to focusing on the best part of your job: solving data science problems! Thank you for reading!<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\"><li><em><strong>Link: <\/strong><a href=\"https:\/\/bea.stollnitz.com\/blog\/configure-dev-machine\/\">bea.stollnitz.com\/blog\/configure-dev-machine\/<\/a><\/em><\/li><li><em><strong>Publication date:<\/strong> November, 29, 2022<\/em><\/li><li><em><strong>Author<\/strong>:<a href=\"https:\/\/bea.stollnitz.com\/\">Bea Stollnitz<\/a><\/em><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Interested in topics such as Data Science, Machine Learning, Data Analysis, etc.? Working on windows? Here&#8217;s an article explaininng how you can setup your box for such tasks. Introduction In&#8230; <a class=\"read-more-link\" href=\"https:\/\/tbekk.com\/devstream\/2022\/12\/02\/configuring-your-windows-development-machine-for-data-science\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,111,10],"tags":[160,127],"class_list":["post-700","post","type-post","status-publish","format-standard","hentry","category-article","category-dev-tools","category-development","tag-datascience","tag-windows"],"_links":{"self":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/comments?post=700"}],"version-history":[{"count":1,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/700\/revisions"}],"predecessor-version":[{"id":701,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/700\/revisions\/701"}],"wp:attachment":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/media?parent=700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/categories?post=700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/tags?post=700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}