The process of ripple formation on a two-dimensional sand bed sheared by a viscous fluid is investigated theoretically. The sand transport is described taking into account both the local bed shear stress (which is deduced from the resolution of the flow over a 2D deformed bed) and the local bed slope, via a simple nonlinear law. Within this model, a 2D linear stability analysis reveals that the most unstable mode is a longitudinal mode (i.e., it corresponds to sand ripples with a crest perpendicular to the flow). Most importantly, oblique modes are found to be unstable also and can couple to the most unstable mode in the nonlinear regime. We show through a weakly nonlinear analysis that this coupling gives birth to complex 2D steady sand patterns drifting along the flow at constant speed.