You can, however, photograph stars even from a light-polluted city, but it takes careful planning to do so. Similarly it would have been possible to photograph stars from the surface of the Moon, but it would have taken planning to do so, and it was never done.
However, stars and other celestial bodies have indeed been photographed from spacecraft in orbit. The picture at right shows brilliant Venus and bright star Spica as photographed by an astronaut on the ISS. This caption was taken from https://commons.wikimedia.org/wiki/File ... tinent.jpg:
On Dec. 5, 2015, Japan Aerospace Exploration Agency (JAXA) astronaut Kimiya Yui captured this image from the International Space Station of the planet Venus shining bright. Part of the station's Kibo laboratory with the star Spica visible below is seen at the top of the frame. At the time this photograph was taken, Japan's Akatsuki spacecraft, a Venus climate orbiter, was nearing the planet.
So you can indeed see stars from the ISS and other orbiters, but whether or not they will show up in photographs depends on several factors.