# How to properly update python from py37 to py38



## hbauer (Mar 14, 2022)

I have some jails that use a bunch of py37- packages. Is there some sort of elegant way to update them to py38- packages?

Or is it just possible to create a list of them, uninstall the old ones and install the new version?


----------



## SirDice (Mar 14, 2022)

Read /usr/ports/UPDATING:

```
20210425:
  AFFECTS: users of python
  AUTHOR: kai@FreeBSD.org

  The default version of python3 and python was switched to 3.8.

  For ports users wanting to keep version 3.7 as default,
  add DEFAULT_VERSIONS+= python=3.7 python3=3.7 to make.conf

  Following procedures may ease the upgrade:

  For users of pre-build packages:
  # sh
  # for i in $(pkg query -g %n 'py37-*'); do pkg set -yn ${i}:py38-${i#py37-}; done
  # pkg upgrade

  For portmaster users:
  # sh
  # portmaster -o lang/python38 python37
  # REINSTALL="$(pkg info -o "*py37*" | awk '{printf "%s ", $2}')"
  # pkg delete -f "*py37*"
  # portmaster $REINSTALL
  # REBUILD=$(pkg query -g "%n:%dn" '*' | grep py3 | grep -v py38 | cut -d : -f 1 | sort -u)
  # portmaster $REBUILD
  # REBUILD2=$(pkg list | grep python-37 | xargs pkg which | awk '{print $6}' | sort -u)
  # portmaster $REBUILD2
```


----------



## hbauer (Mar 14, 2022)

oh that was easy. I'm not working with ports so thats why I have missed this.


----------



## SirDice (Mar 14, 2022)

Even if you only use packages it will still pay off to regularly read UPDATING. If you don't have a local ports tree you can view the file through the cgit browser: https://cgit.freebsd.org/ports/tree/UPDATING


----------

