Better handling of issues during python setup

Fixes #1151