In the UKPA Section 60(5)(a), (b) says:
An act which, apart from this subsection, would constitute an infringement of a patent for an invention shall not do so if - (a) it is done privately and for purposes which are not commercial; (b) it is done for experimental purposes relating to the subject-matter of the invention; ...
There are other clauses too, for example allowing farmers to use the products of plants they've acquired lawfully.
35 USC 271 has some very limited exceptions too (research related to pharmaceuticals is one IIRC).
It's funny that in the US there is such liberty for copyright but patents seem to be locked down relative to other jurisdictions. I assume you're talking about USA, no one ever seems to note despite it being crucial in discussions of law.