Sometimes stroking them too much while they're inside the cage can cause them to be more nervous than when you just scoop them out. Try just touching him for a second, getting your fingers under him, and just scooping him out and let him chill in your hands.

And then some ball pythons just have a bad temper LOL.

Another possibility is if your temperatures/hides are off, and he's stressed inside his cage.