import sympy
alpha1, r1_x, r1_y = sympy.var('alpha1 r1_x r1_y')
B1 = sympy.exp(-alpha1 * (r1_x ** 2 + r1_y ** 2))
B1.integrate(r1_x)
B1.expand(alpha1)
B1.expand(alpha1).integrate(r1_x)
Symbolic Integration in Python using Sympy