My daughter was constipated for 6 months after potty training, we tried all kinds of foods/drinks/laxatives.
She was holding it in for a week at a time before having a full day of screaming in pain before passing the biggest, hardest poo I've ever seen, and she's a dainty little thing! I was amazed, she was on 4 lots of lactulose a day with no effect. It was awful to see her like this so I really sympaphise.
It was definately a mental thing, she was scared it was going to hurt, so held it in, which made her constipated, which made it hurt, a viscious circle!
Amazingly what worked for us was upping the lactulose so when she eventually did go it was a bit softer, then bribed her with kinder surprise eggs! 'If you do a poo you can have a chocolate egg'. We'd tried bribes in the past with no luck, after this she was actively asking to try and do a poo! Expensive at 59p a time, but worth it, and now she's regular and doesn't mind at all.
A friend who had the same problem, apparently quite common, especially in girls, took her dd to a herbalist, they made up a remedy and showed her how to massage it into her dds stomach, apparently worked.
Hope you sort it soon.