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.
- 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
- 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. - Install Miniconda. Miniconda is just the basics from Anaconda. I think it's the perfect way to go
- 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).
- 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