Medications, such as nonsteroidal anti-inflammatory drugs (NSAIDs), opioids, and antidepressants, may cause constipation. Laxatives can help treat the effects of constipation these medications cause.