Trying to run an implementation of lsqcurvefit from the Optimization Toolbox from Matlab in python trying to implement lsqcurvefit from matlab in python with no success. Below is the matlab code I am trying to port to python:

myfun = @(x,xdata)(exp(x(1))./ xdata.^exp(x(2))) - x(3);
xstart = [4, -2, 54];
pX = [2, 3, 13, 12, 38, 39];
pY = [12.7595, 8.7857, -11.8802, -10.9528, -15.4390, -15.3083];

try
    fittedmodel = lsqcurvefit(myfun,xstart,double(pX),double(pY), [], [], optimset('Display', 'off'));
    disp(&quot;fitted model:&quot;);
    disp(fittedmodel);
catch
end

Below is my matlab output:
fitted model:
    4.8389    3.3577   -2.0000

Below is my python code:
from scipy.optimize import curve_fit
pX = [2, 3, 13, 12, 38, 39];
pY = [12.7595, 8.7857, -11.8802, -10.9528, -15.4390, -15.3083];

def myfun(x, xdata):
            temp_val_1 = np.exp(x[0])
            temp_val_2 = np.exp(x[1])
            temp_val_3 = x[2]
            temp_val_4 = np.power(xdata, temp_val_2)
            temp_val_5 = np.divide(temp_val_1, temp_val_4)
            temp_val_6 = temp_val_5 - temp_val_3
            return temp_val_6
        


        popt, pcov = curve_fit(myfun, pX, pY, p0=([4, -2, 54]))
        print(popt, &quot;\n&quot;, pcov)


and below is my python output:
myfun() takes 2 positional arguments but 4 were given

Any help on this would be greatly appreciated, thank you.
As said in the comments this question is better aligned with stack overflow.
Answer
The problem is that curve_fit assumes ydata = f(xdata, *params) + eps, and you assumed ydata = f(params, xdata) +  eps. If I understand your problem correctly your function could be implemented as
def myfun(xdata, a, b, c):
  return np.exp(a)./ xdata**np.exp(b) - c