Theoretically, sure. The Antikythera orrery is an impressive piece of jewelry, may even have run for hours before jamming. I just don't think a steam engine made from hand-forged and hand-fitted parts will do anything but shake itself to bits.
Well, what I was suggesting was that the steam engine built by Newcomen (I have previously spelt this wrong, my apologies) was built before the first modern lathe built by Thiout, a French clockmaker. Having looked into it a bit, it is more complicated than that, but I'd still suggest it was clock/instrument making (pre 1700) which had the more advanced metal working techniques than gunmakers. The hand gun didn't really take off until the wheel-lock, ie clockwork was introduced to guns, for example.
I don't think Newcomen had any type of regulator, so a few ill-fitting parts may have actually acted like a safety valve and enabled pressure to escape before reaching a critical and potentionally explosive level !
What I think you may be refering to is the mass-production of steam-engines of the later Watt-Boulton partnership, which had taken advantage of a new cannon boring tool, which was itself, powered by a steam engine. The problem Watt faced was that Newcomen had use water on top of his cylinder head as a seal, which due to the change in design had to be replaced by a snugger fitting piston/cylinder, which needed the new lathes/borers to make.
So personally, I would have to suggest that the steam engine could have been invented without access to gunpowder, it may be the input from the cannon making industry which made mass production of Watts more powerful engine possible. But, I could imagine, bell-founders* for one, could have possibly been another source for the invention of a scaled up clockmakers lathe.
* I'm refering to our time again, don't know if the Romans had bells, but they could certainly cast bronze.
IIRC Papin, did try to run his engine on gunpowder at one stage, but again I don't see this as being crucial to the devolpment of the steam engine in general.