Could you tell me which of these phrases is grammatically correct — "anything but" or "anything except"?
If the use depends on context, what are the instances when each must be preferred?
Anything but can be a phrase used to emphasise that something is not what was expected
Example from the dictionaries:
She's meant to be really nice but she was anything but nice when I met her.
In sentences where such meaning is not intended, except (as mentioned by Kris) is preferred since it does not interfere with the above meaning.
"I can't give you anything but love" would be more correctly written "I can't give you anything, except love".
but = except
Both are grammatical. Except should preferably be preceded by a word with a comma. In short and very clear sentences, the comma may be dropped, though.
However, anything but is a kind of set phrase -- use it for effect; anything, except is more clear and preferred in serious writing, use it in general.
Anything but is the commonly used phrase and means not at all. Aside from that, they both mean the same thing more or less. In some instances you may need a pause before except but that depends on context.
anything but not at all (used for emphasis): he is anything but racist.(OED)
We cannot do anything except to work on daily basis.(nytimes)
Mr. Ai said his police minders suggested he could publicly talk or write about almost anything — except the coming party congress.(nytimes)
It's actually 'anything but not', but is used as 'anything but'. Isn't it? For example : I can tolerate anything but bad breath. (which means - I can tolerate anything but not bad breath.)