4. The number of solutions to the equation $\pi^{x-1} x^{2}+\pi^{x^{2}} x-\pi^{x^{2}}=x^{2}+x-1$ is $\qquad$ ( $\pi$ is the ratio of a circle's circumference to its diameter).
4. 2 .

The original equation is transformed into
$$
x^{2}\left(\pi^{x-1}-1\right)+(x-1)\left(\pi^{x^{2}}-1\right)=0 \text {. }
$$

When $x \neq 0,1$, $x^{2}\left(\pi^{x-1}-1\right)$ and $(x-1)\left(\pi^{x^{2}}-1\right)$ have the same sign.
Therefore, $x=0,1$.