That is usually hot melt glue and will often pull off with careful use of some needle nose pliers.
The glue can be softened with heat such as a heat gun but then you have a sticky mess that is likely worse that what you started with.
If you do attempt to swap the parts, either remove the glue first or if possible unsolder the leads before applying force to the part. Either way, you don't want to apply force to the solder pads and traces, that is a fairly sure recipe for disaster.