[step:Use polar decomposition to retract $SL(2,\mathbb R)$ onto $SO(2)$]
For $SL(1,\mathbb R)$, the determinant-one condition gives
\begin{align*}
SL(1,\mathbb R)=\{1\},
\end{align*}
so $SL(1,\mathbb R)$ is a singleton and is simply connected.
Now let $A\in SL(2,\mathbb R)$. By polar decomposition there are unique matrices $Q\in SO(2)$ and $P$ symmetric positive definite with $\det P=1$ such that
\begin{align*}
A=QP.
\end{align*}
Define
\begin{align*}
H:SL(2,\mathbb R)\times[0,1]&\to SL(2,\mathbb R)
\end{align*}
\begin{align*}
(A,t)&\mapsto QP^{1-t},
\end{align*}
where $A=QP$ is the polar decomposition and $P^{1-t}$ is defined by the positive-definite functional calculus. Since $P$ is positive definite with determinant $1$, each $P^{1-t}$ is positive definite and satisfies $\det(P^{1-t})=1$. Hence $H(A,t)\in SL(2,\mathbb R)$ for all $A$ and $t$.
At $t=0$, $H(A,0)=QP=A$. At $t=1$, $H(A,1)=Q\in SO(2)$. If $A\in SO(2)$, then its polar decomposition is $A=A I_2$, so $H(A,t)=A$ for every $t\in[0,1]$. Thus $H$ is a deformation retraction of $SL(2,\mathbb R)$ onto $SO(2)$. Therefore the inclusion $SO(2)\hookrightarrow SL(2,\mathbb R)$ induces an isomorphism on fundamental groups, and from the first step
\begin{align*}
\pi_1(SL(2,\mathbb R),I_2)\cong \pi_1(SO(2),I_2)\cong \mathbb Z.
\end{align*}
[/step]