We report on an extensive study of the viscosity of liquid water at near-ambient conditions, performed within the Green-Kubo theory of linear response and equilibrium ab initio molecular dynamics (AIMD), based on density-functional theory (DFT). In order to cope with the long simulation times necessary to achieve an acceptable statistical accuracy just above melting, our ab initio approach is enhanced with deep-neural-network potentials (NNP) force fields, trained and validated on extensive DFT data. This approach is first validated against AIMD results for the viscosity, obtained by using the PBE exchange-correlation functional and paying careful attention to crucial aspects of the statistical data analysis that are often overlooked. We then train a second NNP to a dataset generated from the SCAN-DFT functional, which is known to describe significantly better than PBE the H-bonding features of different phases of water. Close to melting, the viscosity depends very sensitively on temperature. Once the error resulting from the imperfect prediction of the melting line is offset by referring the simulated temperature to the theoretical melting one, our SCAN DFT predictions of the shear viscosity of water are in very good agreement with experiments.