“ERROR: Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall”
try using the –ignore-installed flag:
sudo -H pip3 install PyYAML --ignore-installed
This works because to upgrade a package, pip first uninstalls the old version, then installs the new version. It is the uninstall step that fails for distutils packages. With the –ignore-installed flag, the uninstall step is skipped and the new version is simply installed on top of the old one.