Hands-on sessions - Exoplanets

✏️ Preparing your Python environment for the MCMC hands-on

Below are instructions to prepare the conda environment for the MCMC hands-on.

You have two alternatives:

  1. Use a conda environment and JupyterLab
  2. Use Google Colab

You can use your favourite environment and code editor, but I may not be able to provide any help.

Linux and Mac

I strongly suggest using (conda)[https://conda.org/] rather than the system Python because it makes environment management easier and makes it easier to delete everything and restart from scratch if you mess up your Python installation.

In Linux, you can get the latest miniconda version directly from the terminal:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Make the downloaded file file executable, then launch it.

chmod 777 https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh

 

Follow the instructions to complete the installation. Write "yes" when asked to add the base environment as default on your .bash file, then relaunch the terminal.

I don't have a Mac, so I can't provide detailed instructions. I suggest you visit the official website.

Windows systems

If you are using Windows, you have three options:

  1. Windows Subsystem for Linux (WSL)
  2. Windows installation of conda
  3. Google Colab: recommended for less powerful computers, as all the calculations will be made online

Option 1 is the recommended option, as you will have a real Linux system perfectly integrated within Windows. Option 2 is a good alternative for small projects. Both options will require a lot of space (several gigabytes) and good processing power.

Option 3 is your way to go if your computer is not very powerful or you don't have a lot of space. You will need to pay attention to saving your output (files and images) before exiting the session, as temporary files are not

In the subsections below you can find more details about the different options.

Windows Subsystem for Linux

Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup. Get more information from the official website.

Before installing and configuring WSL, you need to install [PowerShell for Windows]. Installation instructions can be found here

Instructions to install WSL on your computer can be found on the official website.

Now that you have WSL installed, you can proceed with Linux installation. Here are the official instructions for Ubuntu.

The Internet is filled with tutorials and examples. Here are some (unverified) examples: YouTube link 1YouTube link 2YouTube link 3

Once WSL is installed and running, you can install Miniconda exactly as you would in Linux. Go to the official conda website and download the Miniconda version for x84_64 (you may need a different version if your computer is running on an ARM processor)

bash wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Make the downloaded file executable, then run it.

chmod 777 https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh

 

Follow the instructions to complete the installation. Write "yes" when asked to add the base environment as default on your .bash file, then relaunch the terminal.

Windows installation of conda

I have tested this configuration on Windows 11 (25H2).

Note Parallel computing will not work with this setup; resort to this option only if the WSL road did not work out.

Python packages that require a C++ compiler will not work out of the box on Windows.

You must install the Visual Studio Build Tools for C++. The program will ask you to install additional packages; you must select the C++ development tools for Windows (it should be the first box in the upper-left area). The download will require more than 6 GB.

After that, you can install Miniconda following the official instructions

Setting up an environment in conda

Before proceeding with the installation, I suggest creating an environment dedicated to the Lucchin School using Python 3.13. This is the version I'm currently using during the code.

With conda/anaconda:

conda create --name lucchin_school python=3.13

If you are using a Mac with ARM architecture, the following command should force conda to install x86_64 versions of Python and all packages (many thanks to Jinglin Zhao for the tip):

CONDA_SUBDIR=osx-64 conda create -n lucchin_school python=3.13

To list the available environments, do:

conda env list

The active environment will be marked with a \* To activate the `lucchin_school` environment:

conda activate lucchin_school 

Install the following packages from the terminal: numpymatplotlib, 'dynesty', pytransitpygtc :

pip install numpy matplotlib dynesty pytransit pygtc

You can use any editor of your liking. If you like JupyterLab, install it with this command:

pip install jupyterlab ipympl 

Remember to always activate the environment first before launching any code.

Google Colab

You can use a free Google Colab account to run the code

Inside a Google Colab cell, execute the following commands

!pip install dynesty emcee pygtc 
!pip install pytransit

 

Take some time to understand how to upload and download files into Gogle Colab and how to access them from the Jupyter notebook.