My right leg upper part the muscle hurts I realize exercise but do it but I can barely walk on it why

Ok I was exercising yesterday I know it is suppose to hurt a little but I can’t walk with out limping now so what can I do

It may be exercise-induced compartment syndrome which is due to a pressure build-up within the muscles of the leg causing the interrupted blood flow to the muscle.
A period of rest may be attempted, as well as avoid any activities that causes the symptoms. Consult doctor.