Rely just on the packages listed in the adding:
addons:
apt:
packages:
and remove the further apt-get install lines, e.g.:
sudo apt-get update
sudo apt-get install -y git gcc g++ build-essential python-setuptools python-dev python-pip python-scipy python- numpy python-netcdf python-scientific python-matplotlib python-shapely python-pyproj python-pil gmsh python-pytest