sudo apt install postgresql-10 postgresql-plpython-10 postgresql-plperl-10 libpq-dev
If you have PL/R functions in your existing database, then this is necessary:
git clone https://github.com/postgres-plr/plr
cd plr
USE_PGXS=1 make
sudo USE_PGXS=1 make install
sudo pg_ctlcluster 10 main stop
sudo pg_ctlcluster 9.6 main stop