5. The number of real roots of the equation $\frac{\left(x^{2}-x+1\right)^{3}}{x^{2}(x-1)^{2}}=\frac{\left(\pi^{2}-\pi+1\right)^{3}}{\pi^{2}(\pi-1)^{2}}$ with respect to $x$ is exactly $($ )
A. 1
B. 2
C. 4
D. 6
5. D

From the given conditions, it is clear that $x=\pi$ is a root of the original equation. Let's denote the left side as $f(x)$. It is easy to verify:
$$
f\left(\frac{1}{x}\right)=f(x), f(1-x)=f(x), f\left(\frac{1}{1-x}\right)=f(x), f\left(1-\frac{1}{x}\right)=f
$$
$(x), f\left(\frac{x}{x-1}\right)=f(x)$. Therefore, the original equation has exactly 6 distinct real roots: $\pi, \frac{1}{\pi}, 1-\pi$,
$$
\frac{1}{1-\pi}, 1-\frac{1}{\pi}, \frac{\pi}{\pi-1} .
$$