Applying LOTS of heat is the answer.
I normally use an Oxygen sensor socket to remove them.
It is a 1/2" drive , 7/8", six-point socket.
When used in conjunction with a powerbar, it gets those stubborn sensors out.
I also run an 18 mm thread-chaser into the pipe, before installing a LIGHTLY coated ( Anti-seeze ) sensor.