© Copyright owned by the author(s) under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike Licence. A method to measure the transport coefficients on the lattice is proposed. We introduce a spatially-inhomogeneous momentum source to the Hamiltonian in order to generate a non-equilibrium but steady hydrodynamic flow. Once such hydrodynamic flow is created with appropriate spatial geometries, the transport coefficients are determined from expectation values of the energy-momentum tensor. A Monte Carlo simulation for SU(3) gauge theory is performed to measure the shear viscosity with this method. The effect of the momentum source is taken into account with the Taylor expansion up to the third order. Our numerical result shows, however, that the hydrodynamic flow is not generated up to this order in this formalism.