sklearn.metrics.precision_score uses the binary average by default, which is only defined for the binary use case.
For multi-class/-label classification, you would have to define one of the suggested average settings.
The docs 9 give you some information about each average.