The viscosity of cell membranes is a crucial parameter that affects the diffusion of small molecules both across and within the lipidic membrane and that is related to several diseases. Therefore, the possibility to measure quantitatively membrane viscosity on the nanoscale is of great interest. Here, we report a complete investigation of the photophysics of an amphiphilic membrane-targeted azobenzene (ZIAPIN2) and we validate its use as viscosity probe for cell membranes. We exploit ZIAPIN2 the trans-cis photoisomerization to develop a molecular viscometer and to assess the viscosity of Escherichia coli bacteria membranes employing time-resolved fluorescence spectroscopy. Lifetime measurements of ZIAPIN2 in E. coli bacteria suspensions correctly indicate that membrane viscosity decreases as the samples were heated up. Our results report a membrane viscosity value in live E. coli cells going from 10 to 5 cP, increasing the temperature from 22 {deg}C up to 40 {deg}C.