0
$\begingroup$

I have been using the Mathematica client library for Python, but it errors at random some times when running the program, returning:

wolframclient.exception.WolframKernelException: Failed to communicate with kernel: C:\Program Files\Wolfram Research\Mathematica\13.3\WolframKernel.exe.

Whenever this happens, simply running the program again works just fine, and the Mathematica part of the program works just fine. Maybe 1/10 times, this error will run and I'll just restart the program. It's pretty annoying, and seems to happen totally at random.

The python program I'm running is relatively long, but the place where Mathematica shows up is pretty short:

session=WolframLanguageSession()
null_space=np.array(session.evaluate(wlexpr(generating_string)))
session.terminate()

Moreover, I added code at the beginning that simply loads the session by and evaluates Range[5] then terminates it so as to catch an error at the beginning. However, the code seems to run fine at the beginning but then be unable to communicate with the kernel later on in the same run of the program. Again, just restarting the program lets it run fine.

Any idea what's going on or how this could be fixed?

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica StackExchange! Do you use logging library in python? It should generate a warning ("Socket exception: ...") with a description of error. Also, have you tried increasing STARTUP_TIMEOUT (default is 20 seconds)? $\endgroup$ Commented Jul 26, 2023 at 16:19
  • $\begingroup$ I'm not sure what a logging library is (and googling it did not help). I do get an error saying "Socket exception: Socket operation aborted. Failed to start." at the top, followed by the traceback and then the error outlined above. How do I increase startup timeout and what does that do? The error seems to occur just about instantly upon getting to the line "session=WolframLanguageSession()." $\endgroup$ Commented Jul 26, 2023 at 17:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.