We give an algorithm to compute the following cohomology groups on $U = C^n setminus V(f)$ for any non-zero polynomial $f in Q[x_1, ..., x_n]$; 1. $H^k(U, C_U)$, $C_U$ is the constant sheaf on $U$ with stalk $C$. 2. $H^k(U, Vsc)$, $Vsc$ is a locally constant sheaf of rank 1 on $U$. We also give partial results on computation of cohomology groups on $U$ for a locally constant sheaf of general rank and on computation of $H^k(C^n setminus Z, C)$ where $Z$ is a general algebraic set. Our algorithm is based on computations of Grobner bases in the ring of differential operators with polynomial coefficients.