Creating your data science environment

Do you have a Python environment?

Hai

I notice a lot of people start with installing anaconda and never go past using the base data science environment. Even if you manage to create an environment it might not show up in Jupyter Labs or VSC (what I use). This should get you started pretty quickly to analyse that sweet data.

Anaconda or Miniconda

I have a preference for miniconda. However, if you’re starting out get anaconda from here. You can also set up environments with whatever python package manager you use (probably pip), but this is assuming you have python installed and know what you’re doing.

Anyway, once you have it installed open Anaconda Prompt

Anaconda  base environment

Run the following commands

conda create -n fpse
conda activate fpse

This did something important. It allows creating an environment for your code so that you don’t mess with the base environment nor has the clutter from all the default programs installed with anaconda. Additionally you can export a yaml file of all the things you installed to send it to a friend or your chief investment officer unless you use something like Docker etc. This will allow them to recreate your environment.

Creating a new data science environment in anaconda terminal

Getting Jupyter Lab to work

To get the new environment we made available in Jupyter Notebook you have to go through some more hoops.

conda install ipykernel
python -m ipykernel install --user --name=fpse
conda activate base
jupyter lab

So the first command installs ipython kernel on your new environment while the second one allows Jupyter Lab to see it easily. Since you likely have Jupyter Lab installed from having installed Anaconda on the base environment, you can activate base again and start the beautiful tool that will make your life easier.

You should be able to see your new environment in there now. Click the relevant card to create a notebook using that environment (fpse).

Using your new data science environment in Jupyter Lab

Yey!

Now you can install whatever packages you please and manage your dependencies easily.