Skip to content

Instantly share code, notes, and snippets.

@alexpawlowski
Last active May 17, 2020 21:08
Show Gist options
  • Save alexpawlowski/013a6cb026d4b94cb6fd259008ce9159 to your computer and use it in GitHub Desktop.
Save alexpawlowski/013a6cb026d4b94cb6fd259008ce9159 to your computer and use it in GitHub Desktop.
Getting setup with python on windows

Getting setup with python on Windows

While Anaconda has made it much simpler to get python running on Windows, I think Windows Sublayer for Linux is a really good platform to do coding, especially if you later merge the code you're working on to a container online. Conda (Anaconda's product) is a package manager that takes care of most of the weird things you may encounter programming with windows when you're interfacing with Unix users. Python's built-ins like pathlib do even better.

  1. Enable WSL for Windows. Follow the instructions.
    • 1a. WSL2 is a different way that Windows runs Linux. It's defintely performs better, but requires a version of Windows 10 that's not available on stable release until late May 2020. If you don't mind updating to the required version, it's worth the hassle. Here are the instructions
  2. Install your Linux distro Included the instructions above are details to get the distro of choice from the Windows Store. Keep in mind that WSL is mainly a command line interface, though there are ways to get a gui to run (that is pretty simple), so distro choice is mostly a personal preference, some distros will come with more libraries pre-installed over others. Use Alpine Linux if you want the full lightweight container experience, for example. I tend to go with the latest LTS version of Ubuntu, because of the friendly apt-get install nature to get packages.
  3. Install Miniconda. Miniconda is just the basics from Anaconda. I think it's the perfect way to go
  4. Install packages Now with python on your linux terminal, you can install your packages that you may need for your project using conda install [package-name]. It will also install packages that are requirements.
    • 4a. One thing to note with linux installations, some installations may fail because you will need to install linux modules that aren't included in your base linux distro. Typically when a conda installation fails, in the output in your terminal it will list what linux libraries are missing that your python packages may need, often with what commands you'll need to run.
    • 4b. You may also want to create an environment within your WSL for certain projects that have the python packages you want. Here's more info on conda environments. Or you can create different wsl distros for different projects, the choice is up to you. One thing to note is that there isn't a great way to keep track of what linux libraries you need to install within your environments.yml file, so keep a list of those commands that you may need to install so that you're next time doing this goes smoothly (or for when you transfer this to an online container).
  5. Connect your terminal to your favorite code editor.
    • I personally use Visual Studio Code, they have a great extension to do remote development within their code editor (this works beyond WSL), you can read more here. This works by having VS Code installed as a Windows App, and then it is connecting to your linux terminal through WSL/WSL2.
    • PyCharm
    • Others may work, check with your terminal editor.
    • Additionally, you can enable a GUI interface with wsl using an x server, that could enable you to run emacs / vim right on the linux distro itself. Look here for instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment