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.

49 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
17
votes
1answer
454 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 ...
7
votes
0answers
159 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 ...
7
votes
0answers
136 views

How to pass in-memory images through ExternalEvaluate?

Version 11.2 has a new import/export format PythonExpression. Unfortunately, it doesn't work out-of-the-box with images: And using the ImageData directly is too slow: Anyhow, I have some image ...
6
votes
0answers
152 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 ...
5
votes
0answers
104 views

How to properly call Wolframscript from Python?

I am using Windows 10 x64. If I run the following code in Command Prompt: wolframscript -code ToString[TeXForm["Integrate[Tan[x],x]"]] I get the following ...
5
votes
0answers
40 views

How to monitor progress with external language code?

I'm trying to figure out how to get tqdm (a python progress monitoring tool) to work with ExternalEvaluate and "ExternalLanguage"...
5
votes
0answers
169 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 ...
5
votes
0answers
77 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 ...
5
votes
0answers
83 views

A general question about integrating MMA objects into a python workflow

I recently built a classifier using the built-in Classify command in MMA v11.01. We are exploring the feasibility of using python-based workflow (to be consistent with our company practice) that would ...
4
votes
0answers
77 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 ...
4
votes
0answers
184 views

Using Numdifftools with ExternalEvaluate to calculate the Hessian

I need to compute numerically the Hessian of a numerical (scalar) function. Mathematica does not have a numerical Hessian routine (funny thing..) and so I am using this implementation. However, though ...
4
votes
0answers
179 views

Use conda env for ExternalLanguage cell?

I really like the new 'ExternalLanguage' cell in v11.3. Is there a way to tell the cell to use a specific conda environment, either as default or for a specific input cell? Mathematica can find ...
4
votes
0answers
123 views

Use Mathematica inside web app?

My python code running in a Flask web application needs to return results from Mathematica, what is the best way to achieve this? Are there any examples of this having been done successfully?
4
votes
0answers
398 views

How to run a Mathematica package (.m) from python?

I am new to Mathematica and I need to interface with a Python code that I have. Basically, I have a Mathematica package (.m) with a bunch of complicated functions. I want to use some code from python ...
4
votes
0answers
278 views

How to batch run Mathematica code from Python?

I have this notebook: ...
3
votes
0answers
29 views

How to use ExternalEvaluate in ResourceFunction?

Are there any working examples or best practices for writing ResourceFunction that package or depend on external language code (and package dependencies) through <...
3
votes
0answers
131 views

`ExternalEvaluate` for NumPy: passing numpy arrays

As ExternalEvaluate for python has been introduced recently in V11.2, what is the best practice for passing data between Mathematica and NumPy? As by default, the ...
2
votes
0answers
79 views

Mathematica 12.1 trial version, very slow to evaluate a property in multiple pictures

I am a new mathematica user. I am using the following code to measure the internal rectangle width in some images. When I run mathematica for $1$ image, it takes a short time. Also, it works and it ...
2
votes
0answers
55 views

How add channel for wolframclient using conda?

I want to use the wolframclient Python package in Mathematica. The docs suggest using pip install wolframclient. However, my main Python installation is within ...
2
votes
0answers
83 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 ...
2
votes
0answers
585 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"]...
2
votes
0answers
165 views

Using a POST request to populate parameters for a CloudObject

I am using python (ver. 2.7) in conjunction with Wolfram Language to create and build strings in a query language syntax. I have a successfully deployed an ...
1
vote
0answers
42 views

Passing python data types as function arguments

I've a few python data types ...
1
vote
0answers
55 views

Having trouble moving program from python to Mathematica

I'm trying to move a Covid-19 model programmed in python to Mathematica and I can't figure out how to translate this segment of the code to Mathematica. ...
1
vote
0answers
60 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 ...
1
vote
0answers
249 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 ...
1
vote
0answers
64 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 ...
1
vote
0answers
35 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
196 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
118 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? ...
1
vote
0answers
153 views

How can I ExternalEvaluate Python with tesseract?

...
1
vote
0answers
46 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
0answers
80 views

possibility of using `f2py` for interoperability with Fortran

Although interoperability with Fortran could be realised by using LibraryLink (e.g., Linking FORTRAN with Librarylink), the approach is not so straight forward, in ...
1
vote
0answers
137 views

Calling python code on an image directly (without writing to disk / stdin)

I have lots of image processing code written in python and would like to call it from within mathematica. Is there a way to transmit the image data directly like with c++ and LibraryLink? I'd rather ...
1
vote
0answers
276 views

Issue with WSTP

I'm trying to get Pythonika to work once again - with the latest version of the WSTP. The changes required are not many, basically just three: Change ML to WS Change mprep to wsprep Change mcc to ...
0
votes
1answer
6 views

save a mathematica expression with Root[] as Python expression?

I want to convert a Mathematica expression that uses Root[] to Python (open to using sympy if needed). The expression is: ...
0
votes
0answers
33 views

How to run Facebook Prophet in Mathematica?

I would like to use the Facebook Prophet API for timeseries forecasting in Mathematica. I'm trying to make a function prophetM which takes a list of date, and integer pairs (or a Timeseries object), ...
0
votes
1answer
48 views

Solution for system of linear equations for unknown variables in Mathematica and Python

I have a system of linear equations (here 9) as below: $ 2 a_{\{1,2,1,2,2,1,2,1,2,2\}}+2 a_{\{1,1\}}=1, \\ \left(a_{\{1,2,1,2,2,1,2,1,2,2,2\}}+a_{\{1,2,1,2,2,1,2,2,1,2,2\}}\right)+2 a_{\{1,1,2\}}=1, \\...
0
votes
0answers
59 views

Activating the WolframKernel for Python

I would like to activate the WolframKernel to use Mathematica in Python. Although it worked the first time, later the error ...
0
votes
0answers
55 views

$1)$ Combining codes. $2)$ Editing them. $3)$ Evaluating the outputs

I asked a question here. kglr answer was GOOD because that measurement is what I meant exactly. Due to my knowledge in mathematica (I am a $2$-days user), I have some problems (I believe that users ...
0
votes
0answers
162 views

Convert Mathematica Code To Python

Is there a way to convert Mathematica code to run in Python without running a Mathematica kernel in 2019? I have a long complicated code in Mathematica I would like to run in Python. However due to ...
0
votes
0answers
80 views

Convert Mathematica output to Python code

I have this Mathematica (output) vector that I'd like to convert to Python: ...
0
votes
0answers
122 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
61 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 ...
0
votes
0answers
187 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
91 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
0answers
224 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: ...
0
votes
0answers
64 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
442 views

FeynRules issue when trying to export UFO file

I am having problems with the UFO file generated by a very simple model using FeynRules. The following error occurs when MadGraph tries to import the "Model_UFO" file: ...