Questions tagged [python]

Questions about interfacing with, or features inspired or demonstrated by Python--a programming language featuring a dynamic type system, automatic memory management, and a comprehensive standard library.

Filter by
Sorted by
Tagged with
6
votes
1answer
66 views

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

ExternalEvaluate[pySys, pyCmd] evaluates to Failure[...] every time pyCmd contains some ...
4
votes
1answer
139 views

apply python's sympy function in mathematica

I recently try this $$\int\frac{\mathop{\rm Si}(x)}x\,dx$$ Mathematica failed to calculate it. Integrate[SinIntegral[x]/x, x] Mma 11.3 failed,but 12.0 can do it....
0
votes
1answer
67 views

Convert Mathematica expression to Python expression [closed]

I really need to convert this expression to python language, however I am having trouble converting Bessel function (Actually I have several similar expression and to know how to convert really would ...
2
votes
0answers
30 views

Failed to start python external session

I use Wolfram Mathematica 12 on Windows 10. Whey I try to register external evaluator RegisterExternalEvaluator["Python", "C:\\Python27\\python.exe"] it fails ...
10
votes
1answer
194 views

How to display images inside Mathematica with matplotlib

How to display images inside Mathematica with matplotlib. A new window is generated by default, but is it possible to display the picture directly in the notebook? Like this: related: How to ...
8
votes
2answers
121 views

How to add new python type translation to ExternalEvaluate?

Seems like Mathematica can only import basic types (lists, numpy objects, etc). Is there a way to tell Mathematica how to understand arbitrary python objects?
0
votes
0answers
51 views

A MeijerG function does not accep arguments wrapped in “*Form” for numeric evaluation [duplicate]

I get the following Meijer function as a result of a symbolic integration: expr = MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, x]. I try to calculate numerical ...
6
votes
0answers
86 views

Pass Numpy array to Compiled Code (Wolfram Engine, Wolfram Client, Python)

What List-like structures in Python can Wolfram Client handle and how can support for new structures be added? In this answer I describe how to execute from Python, code in a Mathematica package that ...
5
votes
1answer
127 views

How to execute an existing notebook with Wolfram Engine?

[My related question: mwe-for-compiling-functions-into-standalone-dll-and-calling-them-in-python - here I am exploring an alternative] I have downloaded, installed and activated the wolfram engine (...
1
vote
0answers
33 views

Wolfram Engine - how to list and terminate sessions?

Using WolframClient from Python (Jupyterlab notebook) I have at least one session - possibly more: there are three instances of WolframKernel running, possibly due to previously starting a new session ...
5
votes
0answers
53 views

MWE for compiling functions into standalone DLL and calling them in Python?

I have read calling-a-compiledfunction-dll-from-outside-mathematica and the CodeGeneration tutorial and scanned other related questions too numerous to mention, but I am still unclear about how to ...
0
votes
0answers
58 views

Convert Mathematica output to Python code

I have this Mathematica (output) vector that I'd like to convert to Python: ...
6
votes
1answer
221 views

How to open a Python interpreter input cell?

Something weird just happened to me: I mis-typed a keyboard shortcut, hitting the wrong keys, and a new notebook opened up with a Python prompt! Just for grins, I tried entering some simple Python ...
2
votes
1answer
142 views

Is NumberForm double rounding numbers?

A number like 0.644696875 is represented internally as 0.6446968749999...: N[FromDigits[RealDigits[0.644696875, 2], 2], $MachinePrecision] (* 0.6446968749999999 *) ...
1
vote
0answers
99 views

ExternalEvaluate of Python do not work (Anaconda)

I cannot get the ExternalEvaluate work for my Python. It says "missing dependencies" for the registration status. I have attached screenshots from Mathematica and Terminal. From the terminal ...
4
votes
5answers
694 views

List comprehensions in Mathematica?

I'm looking for an implementation of list comprehensions in Python (nested for-in statement with destructuring and conditionals). Here's an example: ...
0
votes
0answers
118 views

Use FacialFeatures in Python Web API?

Under the hood, FacialFeatures uses the net-model ResNet-101 Trained on Augmented Casia WebFace Data. I would like to see a tutorial-style answer on how one would ...
0
votes
0answers
36 views

External evaluation failed

Can someone help me with the ExternalEvaluation with Python. I think the problem is that for some reason my Python is not registered due to the error "MissingDependencies". A screen shot of the error ...
2
votes
0answers
46 views

Auto-completion for Python commands in console of Mathematica notebooks [closed]

A great feature introduced in Mathematica v11.3 is the embedded external language console: https://www.wolfram.com/language/12/external-system-integration/evaluate-python-in-a-notebook.html?product=...
6
votes
0answers
144 views

Export ImageCases to Python?

I’d like a tutorial on how to export a bounding box detector network to mxnet, (for bonus points: convert to Tensorflow), and then get it running correctly in python! Some related questions exist for ...
0
votes
0answers
103 views

Export list of matrix from mathematica to python

I want to have a simple method to export a list of matrix from mathematica to python. Consider the following code: Mathematica : ...
0
votes
0answers
50 views

Using Python in Mathematica : RegisterExternalEvaluator doesn't work

I followed this tutorial https://reference.wolfram.com/language/tutorial/ConfigurePythonForExternalEvaluate.html, installed zmq, restarted mathematica and put this code: ...
0
votes
1answer
106 views

What is the analog of Query in python? [closed]

Is there an analog of Query[] in Python 3.8+?
17
votes
1answer
421 views

How to connect to an already running interactive Python session?

As Mathematica has the interoperability with Python since M11.2, with major improvements in M12.0, is it possible to connect to already running interactive Python sessions? For example, can we connect ...
0
votes
0answers
53 views

Plotting correlation between two metrics that contain hundreds of thousands of data points

I wanted some feedback on what is thought of as best practice in terms of showing correlation between two metrics in terms of minutes vs minutes when both metrics contain a large amount of data points ...
0
votes
0answers
83 views

Why does ListSurfacePlot3D yield a different surface fit than using Python code for best-fit quadratic curve (2nd-order)?

Using the same data, I obtain different surface fits on Mathematica (using ListSurfacePlot3D) and Python (using a code for best-fit quadratic curve (2nd-order)). Here's my code on Mathematica: ...
1
vote
1answer
158 views

How to get Python WolframClient library to connect with WolframKernel on Linux?

My question is similar to the one posted here: WolframEngine install + wolframclient for Python on Ubuntu. However, this solution is not fixing my problem. I cannot get the wolframclient library to ...
4
votes
0answers
62 views

Built-in function (or terse method) to convert from DateObject to Python datetime in Python?

When using the Wolfram Client Library for Python in a Python program there appears to be no built-in function to convert a DateObject in to a Python ...
0
votes
0answers
41 views

Unable to import local Python module to ExternalEvaluate session

Ever since upgrading to Mathematica 12, I have been unable to import a local module in Python that I need for an ExternalEvaluate session. Here is what I have that worked perfectly in Mathematica 11 ...
1
vote
0answers
35 views

Listing variable attributes and methods (python dir() function translation)

Is it possible to list the attributes/methods available to variables in mathematica in a similar way that python does? For instance in python I can run ...
3
votes
2answers
156 views

How to turn a Python array into Mathematica List?

I am running a = RunProcess[$SystemShell, "StandardOutput", "python2 fit.py"] which returns "[ 0.04044647 0.75243326 -0.42992283]\n[ 0.04163976 0.15076435 ...
7
votes
2answers
512 views

How to read .npy file in Mathematica?

I have a .npy file which is created by numpy of Python as below:- ...
21
votes
1answer
1k views

How can I use the Python library networkx from Mathematica?

Is there an easy way to access the Python library networkx from Mathematica? The improvements to ExternalEvaluate in Mathematica 12.0 should make this feasible.
1
vote
0answers
72 views

Difficulty with ExternalEvaluate

I am trying to import a Python function or execute a Python script from inside Mathematica, but the ExternalEvaluate command drives me nuts. I proceed cautiously ...
32
votes
1answer
5k views

Numerical integration — Mathematica vs Python (w/ Scipy) performance

I'm about to tackle a problem that involves a lot of (multi-dimensional) numerical integrations and also subsequent optimizations, and so I want to make sure at least the integration step is as fast ...
1
vote
0answers
28 views

Connect to running external session?

Is there some way to connect to an already running process in the same way that StartExternalSession starts a process?
1
vote
0answers
104 views

How can I efficiently call an external Python script that needs to run continuously?

I am writing a Mathematica program that tries to run 100+ Python programs, via StartProcess[], continuously. It seems to work when I run < 100 programs, but, at ...
1
vote
0answers
241 views

Can't register python in ExternalEvaluate

I had Anaconda 3 installed on my system and python registered with the following link: RegisterExternalEvaluator["Python","C:\\Users\\atfai\\Anaconda3\\python.exe"]...
1
vote
0answers
191 views

Mathematica Reduce function in Sympy [closed]

I am now using Mathematica to compare two big expressions with Reduce function. However, since these two expressions are very complicated, I can not get an answer ...
1
vote
0answers
94 views

How to install only Wolfram Kernel and register to a MathLM Server?

I have access to a MathLM server and the Mathematica 11.3 install files. Is there a command line option for the install that will only install the Wolfram Kernel and not the Mathematica front-end? ...
3
votes
1answer
188 views

Is there any way that convert entire mathematica code to java or python?

I am novice to Mathematica. I want to convert Mathematica code from my textbook to Java or Python to trace coding.
66
votes
8answers
11k views

What are the Wolfram Language's relative strengths for machine learning?

I see a low use of Mathematica in Kaggle competitions. Why would one use the Wolfram Language versus R, Python, or Julia for machine learning? Besides prettier plots and the Manipulate function, ...
0
votes
1answer
88 views

Convert string representation of matrix to matrix

I have a Python script which generates and outputs Mathematica matrices. I use RunProcess to run my Python script and I extract the StandardOutput which is the Mathematica matrix as a string. What I ...
38
votes
3answers
19k views

Mathematica vs. Python - how does Mathematica compare to Python's scientific computing suite?

Python's family of packages for scientific computing has matured rapidly. I can pretty much replicate all of Mathematica's functionalities, but with production level and open-source code using the ...
1
vote
0answers
145 views
1
vote
0answers
45 views

ExternalEvaluate Python print is printing an extra empty cell with newline

When using print command in ExternalEvaluate["Python","print(1+1)"] or ExternalLanguage cell using >, there is always an extra ...
1
vote
1answer
45 views

Using ExternalEvaluate within ParallelDo

I have had great success using Python in Mathematica (for some computations for which there are very well optimised Python packages but not for Mathematica). I have some Mathematica functions that are ...
4
votes
1answer
375 views

How to register Anaconda3(Python3.7) as external evaluator enviroment?

I have installed Anaconda3 (version 5.3.1 for Windows with Python 3.7, 64-bit) as the Python working enviroment, but when trying to register it as an external evaluator, it ...
1
vote
1answer
132 views

Python module attributes not recognised in ExternalEvaluate

I have Python installed and running properly. I have a file called test.py with contents c = 5 When I go to the file's ...