Message Boards Message Boards

GROUPS:

Convert simple Python code to Wolfram language?

Posted 10 months ago
2707 Views
|
7 Replies
|
8 Total Likes
|

There is a way to convert Python to Lisp. Peter Norvig talked about it. https://norvig.com/lispy2.html

7 Replies

Should I assume that you already know about ExternalEvaluate [1] and Wolfram Client Library for Python [2][3][4][5] and you still want to convert? If so, I guess you will have to write your own interpreter.

Posted 9 months ago

Interesting but with Python 3.8.1 and Mathematica 12.0 only one line of input works.enter image description here

Posted 9 months ago

Yah, I need to write my own interpreter. Is it hard? Any hint?

Posted 3 months ago

Not sure if you already resolved your Python 3,8x issue(?) - I literally beat my head against the wall for 3 weeks straight fighting the same. Resolved it yesterday around 4am. Here is the simple solution:

1) Locate externalevaluate.py should be in:

C:\Program Files\Wolfram Research\Wolfram Finance Platform\3.0\SystemFiles\Links\WolframClientForPython\wolframclient\utils\

2) Open in whichever editor you use (e.g. Notepad++), and replace line 66 as follows:

exec(compile(ast.Module(expressions, []), '', 'exec'), current) - this is the part you copy/replace.

3) You should restart 12.x and you will find ExternalEvaluate is no longer throwing that error, and opening up a Python shell "shift >" also works just as well. Of course, you will still need to use ExternalEvaluate, however, this is amazing integration!

Now, if Wolfram could post this online in their actual docs hopefully others do not lose as much sleep as I did. :)

Side note - Do not attempt to use Chocolatey to trick Mathematica into updating from 3.7.0 to 3.8.x - it will hang and freeze. What needs to be done is the ability to SystemInstall whichever version of Python we want to install as opposed to being bound to 3.7.0. Sure you can register various versions then restart, but that is not as tightly integrated as the 3.7.0 version SystemInstall does for us.

/Zap

Posted 3 months ago

Maybe some tools like Parenscript, but generates Python code instead of Javascript.

Posted 3 months ago

There is scientific paper from Facebook that can help

https://arxiv.org/abs/2006.03511

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract