In[]:=
ClearAll["Global`*"]
In[]:=
FindExternalEvaluators["Python"]​​session=StartExternalSession["Python"]
Out[]=
System
Version
Target
+
Registered
af448581-00a1-6909-be67-3ef033aea708
Python
3.12.1
C:\Program Files\Python312\python.exe
•
True
Out[]=
ExternalSessionObject
System: Python
Version: 3.12.1
UUID: fad82879-274a-4a33-95a1-12825436a74b

ExternalEvaluate[session,"from scipy import special"](*loadpylibrary"special"*)
externalF[u_]:=ExternalEvaluate[session,"special.ellip_harm(1,2,1,2,"<>ToString[u]<>")"](*callpythonfunction,4constantsand1variable*)​​externalF[10](*exampleofcall*)
Out[]=
9.94987
In[]:=
NIntegrate[externalF[x],{x,0.5,1},Method{Automatic,"SymbolicProcessing"False}](*Integration*)
NIntegrate
:The integrand Failure

Message:
name 'x' is not defined
Tag:
PythonError
 has evaluated to non-numerical values for all sampling points in the region with boundaries {{0.5,1}}.
Out[]=
NIntegrate[externalF[x],{x,0.5,1},Method{Automatic,SymbolicProcessingFalse}]
In[]:=
DeleteObject[session]