In most cases, enclosures and buildings have enough little spaces for the pressure to stay at equilibrium with the outside pressure. Therefore, the sensor does not need to be vented to the outside. It is possible, however, that the rate at which the pressure equalizes is slowed by being in an enclosure, but the rate change usually is not noticeably significant.
If the sensor resides in an absolutely air-tight environment, and the pressure outside this environment needs to be measured, then the sensor will need to be vented to the outside. However, venting to the outside may change the rating of the enclosure or associated inside environment.