Set up Python environment#
You will need a working Python environment to run the examples and to complete the labs in this course.
I choose Python as the main language for this course because Python is a widely used language for data science. Many common algorithms, including ones used in this course, are readily available as Python packages, and resources for Python and Python packages are easy to find. If you wish to use a different programming language, please read Use other programming languages below.
If you already have a working Python environment, it may already be sufficient for this course. However, I strongly recommend that you still create a new environment so that the Python packages you used in this course will not interfere with your original environment. The instructions below will guide you to install conda (if needed) and create a new Python environment.
Use Python on your machine#
First, check if you already have conda
available on your machine.
If you have been using Python on your machine, there is a good chance that you already have conda
too.
You can check whether the conda
command is available from a terminal.
If it is, skip Install conda and jump to Create a new environment directly.
Install conda#
If conda
is not available on your machine, you can install one very easily.
I recommend installing Miniforge, but you can choose Miniconda or even Anaconda if you like.
Simply download Miniforge3 for your OS from this page. Once it’s downloaded, just run the installer and follow the instruction therein.
Near the end of the installation process, you will be prompted to choose whether you want the base conda environment be activated by default.
If you choose no, make sure you copy the command that activates the base conda environment and keep it somewhere handy.
You will need to activate the base conda environment for the conda
command to be available on your machine.
Create a new environment#
Once conda
is available on your machine, you can go ahead and create a new environment for this course.
First, download this environment definition file.
Once it’s downloaded, you can run:
conda env create -f /path/to/environment.yml
Once the package installation is done, you can run the following to activate this new environment:
conda activate 7730
Start JupyterLab#
After the 7730
environment is activated, you can start the JupyterLab interface by running
jupyter lab
Use Python on Google Colab#
If you don’t want to install Python on your own machine, or if you don’t have access to a machine that you can install new software, you can use Google Colab as an alternative.
Google Colab provides free Jupyter Notebook service. To use Google Colab, you will need a Google account, a web browser, and a stable Internet connection. Simply visit https://colab.research.google.com/ to start using the service.
Google Colab already has all the packages that we will use in this course installed,
except for corner
and emcee
.
When you run labs that use corner
or emcee
, please run the follow line in your
Google Colab notebook:
%pip install corner emcee
Use other programming languages#
While I strongly recommend using Python for this course, learning Python is not one of the learning objectives of this course. Hence, if using another programming language makes it easier for you to learn the materials in this course, you are welcome to do so. You can submit the assignments using the programming language you choose.
You will be responsible to translate the provided labs to the language of your choice. Please note that I will not be able to assist the translation, nor can I help you identify packages in other programming languages that offer the functionalities of Python packages that we use.