$$P = K_P\,\rho^{(n+1)/n}$$
non-dimensional radius:
$\xi = \frac{r}{\alpha}$
scaling factor: $\alpha^2 = \frac{(n+1) K_P}{4\pi G \rho_c^{(n-1)/n}}$
non-dimensional density:
$\theta(\xi)^n = \frac{\rho}{\rho_c}$
Using non-dimensionalisation and the polytropic equation of state the stellar structure equations can be simplified to a single equation.
$$\frac{1}{\xi^2}\frac{d}{d\xi} \left( \xi^2\frac{d\Theta}{d\xi} \right) = - \Theta^n$$
lane_emden.py contains a small script solving the Lane–Emden equation numerically for a given $n$.%run -i lane_emden.py
xi, theta = get_solution(1.0)
plt.plot(xi,theta)
plt.xlabel(r'$\xi$')
plt.ylabel(r'$\Theta$')
<matplotlib.text.Text at 0x7f12a4496a20>