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 <...
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 ...
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, ...
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 ...
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 ...
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 ...
14
votes
How to display images inside Mathematica with matplotlib
Seems to be able to embed images by converting to png.
...
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 ...
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:
...
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
...
12
votes
Why does Mathematica use a different $PATH than terminal?
I think this is an OS X issue. Note that if you launch Mathematica from a terminal, you will get the value of Environment["PATH"] which you expected.
For GUI ...
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 ...
11
votes
Accepted
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.
...
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 ...
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:
...
9
votes
Accepted
Why does Mathematica use a different $PATH than terminal?
It is certainly an OS X issue. Assuming the default shell is configured, when Terminal starts up it runs the script file ~/.bash_profile, which usually modifies the ...
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 ...
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 ...
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, ...
7
votes
RunProcess seemingly does not work on my Windows system
Your RunProcess works properly in all examples and System settings are fine.
As @Oleksandr R. has admitted, date is a shell ...
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 ...
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+:
7
votes
Accepted
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
<...
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 ...
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 ...
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:
...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
external-calls × 220python × 57
interoperability × 24
mathlink-or-wstp × 9
windows × 9
scripting × 8
external-language-cell × 8
files-and-directories × 7
linux × 7
webservices × 6
javascript × 6
programming × 5
warning-messages × 5
parallelization × 5
packages × 5
mac-os-x × 5
export × 4
import × 4
evaluation × 4
kernel × 4
java × 4
run × 4
bugs × 3
linear-algebra × 3
dynamic × 3