I've had two ball pythons do this.

What fixed it every time is changing their enclosure. Not just cleaning their current one, put them in a totally new one. Sounds odd, like it would make things worse instead of better. But it has always worked for me. I've done it 4 times total. And they all ate at their next feeding. I let them eat at least 3 times in the new enclosure before moving them back. I haven't had any issues in months.