# Set Up Python Environment for CogSci 131

CogSci 131 (Computational Modeling of Cognition) is one of my favorite classes at Berkeley when I took it with Prof. Tom Griffiths in 2016. Now I’m teaching it in my last semester. Before getting to the fun parts (e.g., implementing recurrent nets and classic RL algorithms like SARSA using vanilla NumPy), one needs to set up the right Python environment. I hope this tutorial can save students some headaches.

# Option #1: Conda Virtual Environment

To avoid nightmares down the line👇, use virtual environments for your local stuff.

1. Install Miniconda: Install the right version for your operating system from this page (I used Anaconda years ago that comes with dozens of pre-installed packages, which is more cumbersome or convenient, depending on the perspective)
1. Create environment: Open a terminal 👉 cd to where you wanna launch Jupyter (for me it’s cd /Users/apple/Documents/spring2022/cogsci131/notebooks) 👉 run this command conda create --name cogsci131 python=3.9.5

• “cogsci131” is the name of the environment; you can use whatever you like
• Python 3.9.5 is the lasted version that conda installs as of writing; replace with the latest version when you do this
2. Activate environment: In the same directory, run conda activate cogsci131

3. Install packages: For this course (or cognitive science in general), you most likely need to conda install pandas numpy scipy matplotlib seaborn jupyterlab pandoc

• After all the installations are completed, you should be able to launch Jupyter Lab from this environment: jupyter lab
4. (Optional) Export environment: If for some reason you need to recreate the above environment (nuked it or changed computers), you can export the settings to a YAML file (conda env export > cogsci131.yml) and create a new environment from the saved file (conda create --name cogsci131 --file cogsci131.yml)