Getting a usable python environment (in WSL or in Linux)
I strongly recommend people use anaconda (AKA conda) to manage their python installation. The full instructions can be found here. If you are working in Ubuntu through WSL, follow the instructions for Linux/Debian. I'll provide a quick TLDR here:
-
Install the prerequisites
-
Scroll to the bottom of this page and copy the link address for the Linux install, something like "64-Bit (x86) Installer (581 MB)" i.e. right click "Download" and hit Copy link address)
-
Run
wget <THE LINK ADDRESS
to download the file (Note: you can just download it from the browser, but if you are working in a virtual machine/on a cluster/in WSL you'll then need to move the file from your local machine to the target. Usingwget
directly skips this step). -
Install
anaconda
by runningbash ~/PATH/TO/FILE
where theFILE
will be something likeAnaconda3-2020.02-Linux-x86_64.sh
-
Finally, once you have installed
conda
and restarted, your command prompt will have start with(base)
. This tells you that you are in thebase
conda environment. DO NOT INSTALL THINGS IN THE BASE ENVIRONMENT. -
Instead, follow this guide to create a new environment. For example, to create an environment called
testing
withpython 3.9
, runconda create -n testing python=3.9
. Once complete, you'll need to activate the environmentconda activate testing
. -
While
conda
may seem like a headache (you will no doubt forget to activate the environment occasionally and wonder why nothing works!). This headache is minor compared to the headache which occurs when you need to install two different versions ofnumpy
for two different projects. As such, use a new environment for each project you work on.