35 votes

How can I use the Python library networkx from Mathematica?

Mathematica 12.0 brings two new features that make this easier to do than it was before: ExternalFunction Wolfram Client for Python Below we implement a function <...
Szabolcs's user avatar
  • 234k
20 votes
Accepted

How to use the library exported from FunctionCompileExportLibrary outside of Mathematic (e.g., in Visual Studio)?

This is a quick example of calling the exported compiled function from a standalone executable on Windows. A few things to note which are currently undocumented and that can definitely be subject to ...
ilian's user avatar
  • 25.5k
18 votes
Accepted

FindExternalEvaluators["Python"] gives me an uninstalled version of Python

Update: As of version 12, one should use FindExternalEvaluators["Python", "ResetCache" -> True] To turn my comment into an answer, ...
ilian's user avatar
  • 25.5k
18 votes
Accepted

How can I use Python's SciPy and NumPy functions in Mathematica to find the minimum of a function?

I believe you're not in the correct direction, optimizing your Mathematica code should be more practical and easier. (You've already learned the numeric capability of Mathematica under your previous ...
xzczd's user avatar
  • 65.4k
16 votes

ExternalEvaluate for Python fails with Import::nopythonevals

To get this out of the way: I believe the Import::nopythonevals message will be issued by Import[..., "PythonExpression"] if ...
Szabolcs's user avatar
  • 234k
14 votes
Accepted

"ExternalLanguage" cell with ExternalSessionObject

This has to be done at the stylesheet level and here's a way to do it. First we'll make a new CellEvaluationFunction that uses the ...
b3m2a1's user avatar
  • 46.8k
14 votes

How to display images inside Mathematica with matplotlib

Seems to be able to embed images by converting to png. ...
Aster's user avatar
  • 3,836
14 votes

How can I use Python's SciPy and NumPy functions in Mathematica to find the minimum of a function?

The first solution will use socket to connect python and Mathematica. We'll set up a server that returns the result of the function that has been defined in ...
Ben Izd's user avatar
  • 9,169
13 votes
Accepted

How to obtain the distance (in Km/Miles and in minutes) by road ?. for example using googlemaps

You can use TravelDistance and related functions to find the distance by road. Example: ...
Szabolcs's user avatar
  • 234k
12 votes

How to run a shell script from inside Mathematica

The issue here is that when Mathematica executes an external system command, at least on Linux, it does so from the current directory. You can verify this via ...
Jason B.'s user avatar
  • 67.9k
12 votes
Accepted

How to open a Python interpreter input cell?

Type > at the start of a cell (or when between cells). This is documented in an example on ref/ExternalEvaluate (last Basic Example). I'm a bit suprised it's not in the details section. It probably ...
Itai Seggev's user avatar
  • 14.1k
11 votes
Accepted

Corresponding built-in types for Python

I think you can find what you're looking for here:
ktm's user avatar
  • 4,232
11 votes

How to add new python type translation to ExternalEvaluate?

A class who inherits the WLSerializable class and overrides the to_wl method can be automatically converted. ...
Aster's user avatar
  • 3,836
11 votes

Is it possible to call back to Mathematica when using Python through ExternalEvaluate?

I'm Riccardo Di Virgilio, one of the developers of ExternalEvaluate and wolframclientforpython. There is a way to do what you want, even if the function is not documented or exposed, so the code I'm ...
Riccardo Di Virgilio's user avatar
10 votes

Getting data into Julia session?

Fortunately, the Wolfram team had done the hard part for us. We don't have to build interface to call julia (in most cases). First, start a session: ...
Ben Izd's user avatar
  • 9,169
9 votes

Installing R libraries for use with ExternalEvaluate?

I was able to follow Leonid Shifrin's directions here for Mathematica 12.2 and R 4.0 running on Mac OS X 10.15.7. (I verified that R packages installed by me are accessible through RLink.) See the ...
Anton Antonov's user avatar
8 votes

Interfacing Mathematica with Tableau desktop

This answer is a copy of my Mathematica and Tableau integration GitHub repository. Before you start reading I should mention that even when you are using tabpy, you can only run python code inside ...
Ben Izd's user avatar
  • 9,169
8 votes
Accepted

Within Mathematica, how to export the output of python code to the Mathematica expression?

Even if the session was still open External code cell will be open after executing, you can't use the same variable name you'd defined in the external session, ...
Ben Izd's user avatar
  • 9,169
7 votes
Accepted

RunProcess doesn't list files on Windows

It will work if you send a newline at the end of dir: RunProcess[$SystemShell, All, "dir\n"] (* note the \n *) What I do not ...
Szabolcs's user avatar
  • 234k
7 votes
Accepted

Use conda env for ExternalLanguage cell?

You can do this with SetLanguageCellSession. I've just answered a similar question here, see that answer for an explanation of how what you want can be done in version 12.1+:
M.R.'s user avatar
  • 31.4k
7 votes
Accepted

Run Does not Work

Files Let's create some test files ...
rhermans's user avatar
  • 36.3k
7 votes

Using ImageJ filters directly from Mathematica through J/Link

This is not an answer to the main question on how to do it in Mathematica but merely one possible reason why this whole thing might not be achievable. In Java, your exact example looks like this <...
halirutan's user avatar
  • 113k
7 votes

Control a Mathematica kernel from the front-end and from python

For this I'll make use of a little thing I recently wrote to answer a much deeper question: Control Front End in "mathlink" mode The heart of this will be a little package to make a kernel ...
b3m2a1's user avatar
  • 46.8k
7 votes
Accepted

How to use VBA types with UNDERLINE in it's name in NETLink?

Quoting from the Underscores in .NET Names subsection within the Calling .NET from the Wolfram Language section of the NETLink Tutorial: .NET/Link maps underscores in type, method, property, and ...
WReach's user avatar
  • 68.7k
7 votes

How to link C++ code through the new compiler in V12?

Too long for a comment, but this (undocumented) syntax works in version 12.3 with a minor modification and taking into account a renamed function, for example: ...
ilian's user avatar
  • 25.5k
7 votes

How to extend External Language Input?

It was just an attempt to add a ExternalCell, and did not successfully create an evaluator bind. First create a new package called ExternalEvaluate_*, only this ...
Aster's user avatar
  • 3,836
7 votes
Accepted

ExternalEvaluate[pySys, pyCmd] evaluates to Failure[...]

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 ...
Michael Himbeault's user avatar
7 votes

How to assemble Python abstract syntax trees (AST) in Mathematica?

I am not sure what exactly you are looking for. I think the answer of your question: I am trying to programmatically generate Python code in MMA [...] and then submit it to Python for evaluation. I ...
Anton Antonov's user avatar
7 votes

Calling a Python class function from ExternalEvaluate

It is an extended comment to the answer by Ben Izd. The simplest interactive solution for his example is as follows: ...
Alexey Popkov's user avatar
7 votes

Use function defined in Mathematica from Matlab

Although the first question was about transferring a specific function from Mathematica to Matlab, with little change, it would be possible to call any Mathematica function from Matlab, a feature that ...
Ben Izd's user avatar
  • 9,169

Only top scored, non community-wiki answers of a minimum length are eligible