Adding to the useful tips so far, is to be aware of the attitude of the neck of the guitar. Specifically, its angles. Check the angle (taken from above) that it makes with your body. Pushing out or pulling in, parallel to the ground, (like the hand of a clock) will make differences that might solve the problem.
Next angle check is the 'verticalness' of guitar, thus neck. Some players need to look at the fingerboard, so tip the guitar so it's not vertical. That in turn causes fretting to be more difficult.
Next angle to consider is the 'horizontalness' of the neck. This can make a big difference to fretting - particularly barres. We're all different, but by changing that (and other) angles, life can be made so much easier.
Also check on where the guitar is on your body - which leg it rests on, whether it's central, whether you're seated or standing, how high/low the guitar is slung. All angle-related.
A bass student of mine struggled to play a passage, so I asked him to raise the neck, close to vertical. Reluctantly he did, and played the passage perfectly first time. Doing that changed all the angles, making it achievable.