fixed annoying errors when installing in both python2 and python3

The issue was half fixed in pull #2875, but got closed for some reason. This fixes both the py2 and the py3 errors relating to calling exec funny.