I have a python program which makes some optimization via scipy.optimize.differential_evolution(...). My python program works properly if I launch it via double-click or PyCharm (using system interpreter, Python 3.6.8). But If I try to launch it from LabVIEW 2019 (32-bit) by Python Node, I have a mistake with differential_evolution method. The problem is in differential_evolution method because the mistake vanishes when I turn off this method. The problem can't be in input (from LabView) arguments because I don't use these LabView arguments in my function now.
My function which I call is shown on the below snippet:
def make_in_labview()
#initialization of constants like bounds for optimization e. t. c.
...
# Main problem:
result = sp_opt.differential_evolution(func=myClass.deviation, bounds=optimization_bounds, args=[[empiric_set, funcs, False]],
strategy='best1bin', maxiter=10, tol=0.0001, popsize=30,
mutation=0.35, recombination=0.7, workers=2)
# (sp_opt - scipy.optimize)
return 0
Here is main mistake which LabView outputs:
Function Name: make_tomography Python returned the following error: <class 'AttributeError'> module 'sys' has no attribute 'argv'
And here is seemingly unuseful Stack information about problem's source
*Call Stack information: File "C:\Users...\main.py", line 3171, in make_tomography result = chip.optimization_diff_evolution(optimization_bounds, [empiric_set, funcs, False])
File "C:\Users...\main.py", line 564, in optimization_diff_evolution mutation=0.35, recombination=0.7, workers=2)
File "C:\Users\QPrac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\scipy\optimize_differentialevolution.py", line 307, in differential_evolution constraints=constraints) as solver:
File "C:\Users\QPrac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\scipy\optimize_differentialevolution.py", line 501, in init self._mapwrapper = MapWrapper(workers)
...
e.t.c. similarly or about multiprocessing like
File "C:\Users\QPrac\AppData\Local\Programs\Python\Python36-32\Lib\multiprocessing\context.py", line 119, in Pool context=self.get_context())*
Can you help me to understand the problem?
P.S. Also, I have only python 3.6.8., 32-bit (as It needs to work properly with LabVIEW 32-bit) I installed on my Windows. My Windows is 64-bit, but I haven't an opportunity to install LabVIEW 64-bit.
The problem has been solved: if you use LabView's python node, you should to accurately check how you pass additional arguments (i. e. 'args' according to scipy manual) to the diff evolution method of scipy.