The goal of such "rules" isn't to prevent scholars from moving with their libraries, but to restrict the potential practice of commercial brokers from taking advantage of regional discounts and immediately reimporting them into place without those discounts.
It might even be questionable whether "ILLEGAL for sale..." could be enforced in any case, though copyright restrictions need to be observed.
I think the worst that would happen is if some customs officer "raised an eyebrow" if you carried a few books across a border. But the eyebrow raising would likely be followed by a smile.
It might be technically illegal for you to resell books in some places, but there would really be no one to enforce such a "law" for a private sale. It would be a different matter if you had a hundred copies of the same text, of course because now the publisher might take notice.
And such laws are much more likely to be civil in nature, requiring a lawsuit and not a criminal matter.
There is a general principle in the law, though it is informal: The law does not concern itself with trivialities.
But, I'm not a lawyer. I try to judge such things with common sense.
Note also that the standard boilerplate printed in the front matter of most books (in the US, say) imply that you have fewer rights than you do. They don't, generally, mention fair use exceptions. "No part of this book may be reproduced in any form..." That is really wishful thinking on their part, not actual law or regulation.