8
$\begingroup$

ExternalEvaluate[pySys, pyCmd] evaluates to Failure[...] every time pyCmd contains some import statement (otherwise it just works).

The result says it is a Python-related error:

TypeError required field "type_ignores" missing from Module

The "problematic" files seem to be:

C:\Program Files\Wolfram Research\Mathematica\12.0\SystemFiles\Links\WolframClientForPython\wolframclient\language\decorators.py

C:\Program Files\Wolfram Research\Mathematica\12.0\SystemFiles\Links\WolframClientForPython\wolframclient\utils\externalevaluate.py

Both Mathematica 12.0.0 and Python 3.8.1 are fresh installations.


EDIT It is indeed a problem with Python 3.8.

Also, in:

C:\Program Files\Wolfram Research\Mathematica\12.0\SystemFiles\Links\WolframClientForPython\setup.py

it is clearly visible that 3.8 is not """officially""" supported yet.

However, see the accepted answer for a clever workaround.


TL;DR The problem is not present as long as you stick to Python <= 3.7.x, but Michael Himbeault did an awesome job making 3.8.x work as well.

$\endgroup$
7
$\begingroup$

Reading this, turns out the patch is a one-line fix to enable Python 3.8 support. I haven't tested it extensively, but I've included it in my GitHub gist that also lets you use Python runtimes installed from the Microsoft Store.

Patch reproduced here directly (applied to 12.0.0) for C:\Program Files\Wolfram Research\Mathematica\12.0\SystemFiles\Links\WolframClientForPython\wolframclient\utils\externalevaluate.py:

66c66
<         exec(compile(ast.Module(expressions, []), '', 'exec'), current)
---
>         exec(compile(ast.Module(expressions), '', 'exec'), current)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Hi, thank you! As soon as I get to my laptop I'll try your fix ;) if it works on my machine (of course it should, but for the sake of full transparency I'll wait until I actually try) I'll accept your answer! $\endgroup$ – Spaghetti Jan 16 at 7:52
  • $\begingroup$ For the same situation of Mathematica 12.0.0 and Python 3.8.1 in MacOS, this solution simply solved the problem. Great. $\endgroup$ – Joo-Haeng Lee May 17 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.