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
18
votes
1answer
479 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
229 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 ...
7
votes
0answers
267 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 ...
7
votes
0answers
217 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 ...
6
votes
0answers
154 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
66 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
103 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
850 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"]...
5
votes
0answers
85 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 ...
5
votes
0answers
453 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
1answer
427 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
0answers
83 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
202 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
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
283 views

How to batch run Mathematica code from Python?

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

Create “Python Code” cells using custom executable

In https://mathematica.stackexchange.com/a/155815/45020 it is explained how to run cells using a custom virtual environment. How can I quickly create a cell that is evaluated using this environment. ...
3
votes
0answers
37 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
139 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
37 views

Exporting packages containing “Python Code” cells

I created a notebook with Python code cells (evaluated using External Evaluate) as can be created by typing > at the beginning of a cell. (And choosing Python ...
2
votes
0answers
67 views

Resources on python programming for Mathematica programmers

Are there any good guides to programming in python for people who are already very familiar to Mathematica. I understand that for some things the canonical python approach is different and it is good ...
2
votes
0answers
78 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
86 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 ...
2
votes
0answers
172 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
47 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), ...
1
vote
0answers
70 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
89 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

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 ...
1
vote
0answers
131 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: ...
1
vote
0answers
82 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
36 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
219 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
126 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
170 views

How can I ExternalEvaluate Python with tesseract?

...
1
vote
0answers
51 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
138 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
284 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
0answers
81 views

Missing Dependencies for Python

I have some python code that I'd like to try to use in my Mathematica notebook. I have tried following the setup guide but I have run into some trouble (Mac). The Mathematica setup documentation says ...
0
votes
0answers
24 views

How to use conda environments in StartExternalSession?

I am trying to get a conda python environment to run in Mathematica under Windows. It includes the following packages (in case you want to reproduce): ...
0
votes
0answers
45 views

How to go from a Pareto Distribution in Scipy to a Pareto Distribution in Mathematica?

Assume that I have fitted a Pareto distribution via Scipy and have gotten the following parameters: ...
0
votes
0answers
36 views

Kernel crashes on invoking Python prompt

Apologies if this is a naive question. A typing error keeps crashing the kernel. My typing error is to start a line with ">", unintentionally invoking Python. The problem is that this ...
0
votes
0answers
78 views

What's going on in this Newton-Raphson algorithm?

I'm looking at this post, over on Mathematics SE. I'll summarize here: A signal with a known velocity, c is emitted by some source. We're given the coordinates of ...
0
votes
0answers
84 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
113 views

Convert Mathematica output to Python code

I have this Mathematica (output) vector that I'd like to convert to Python: ...
0
votes
0answers
125 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
85 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
273 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
362 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
67 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
475 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: ...