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
12
votes
1answer
164 views

Problem passing a list from Mathematica to external python function

comp1a = Flatten[Join[{{0 + 0 i}}, {comp1}]]; Flatten[comp1a[[1 ;; 6]]] This creates a list of complex values -> comp1a The first 6 terms in the list are: {0, -...
3
votes
1answer
50 views

Formula translation from Wolfram Python Client Library to Python usable string

I try to use the Wolfram Python client library to evaluate a differential equation in Python. This does not work smoothly, but using ...
0
votes
0answers
51 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 ...
2
votes
0answers
72 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 ...
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 ...
1
vote
0answers
52 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. ...
2
votes
1answer
59 views

Missing Dependencies for Python in Conda in MMA 12.1 in Windows 10

I tried to run python code in MMA 12.1 on my Windows 10 computer. However, it seems that the python in conda has MissingDependencies, as shown below. According to this FAQ thread, https://support....
5
votes
0answers
85 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 ...
3
votes
1answer
109 views

Python module error using Externalsession

What I am trying to do is to generate an array using Python inside Mathematica but I getting TypeError required field:type_ignores missing Module. Here is the image:...
2
votes
0answers
27 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
2answers
130 views

Using Manipulate to plot a function's time evolution

I am trying to plot a function in Mathematica using Manipulate to check how a function evolves with time. I am able to get sensible results with Python, though in Mathematica there is an overshoot in ...
5
votes
1answer
40 views

How to set default version for an external language code cell?

This example is for Python but I would like to set this option for any external language. I have a couple of versions of Python installed. ...
5
votes
0answers
39 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"...
2
votes
0answers
25 views

Get Box Shape Coordinate from image [closed]

I would like to taget each box (rectangle) in this image in order to have the coordinate of each one and finally crop on each one. For example, I have 3 rectangles in the image, I would like to ...
5
votes
1answer
166 views

How to run a Mathematica package (.m) from Python using the “Wolfram Client Library for Python”?

This question is about calling a Mathematica Package (.m file) from Python employing the "Wolfram Client Library for Python" (https://github.com/WolframResearch/WolframClientForPython). For ...
6
votes
1answer
88 views

RegisterExternalEvaluator claims MissingDependencies even though ZMQ is installed

I have an Anaconda Python installation in a non-standard location. So I ran RegisterExternalEvaluator["Python", "path-to-python.exe"] But I got the following ...
5
votes
1answer
448 views

Convert python Code To Mathematica?

Is there a way to convert simple python code to Mathematica code
3
votes
1answer
50 views

How to access WolframWebEngine running on a remote server?

Thanks to WolframWebEngine it's extremely easy to build and run a webapp backed by the Wolfram Engine on a local machine. Assuming one has all dependencies installed on a remote server, what is the ...
-1
votes
2answers
121 views

How to convert this Python code which uses genetic algorithm to calculate the best path into MMA

Question: From a logistics center, multiple distribution vehicles are used to deliver goods to multiple customers. Each customer's location and demand for goods are certain, each distribution ...
2
votes
0answers
50 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 ...
4
votes
1answer
169 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
84 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 ...
7
votes
1answer
150 views

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

ExternalEvaluate[pySys, pyCmd] evaluates to Failure[...] every time pyCmd contains some ...
5
votes
0answers
130 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 ...
11
votes
1answer
350 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 ...
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 ...
7
votes
0answers
147 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 ...
1
vote
0answers
55 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
1answer
204 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 (...
5
votes
0answers
72 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
148 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
77 views

Convert Mathematica output to Python code

I have this Mathematica (output) vector that I'd like to convert to Python: ...
8
votes
1answer
242 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 ...
1
vote
0answers
218 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 ...
2
votes
1answer
169 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 *) ...
0
votes
0answers
119 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
57 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 ...
3
votes
0answers
66 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 cell: https://www.wolfram.com/language/12/external-system-integration/evaluate-python-in-a-notebook.html?product=...
0
votes
0answers
166 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
82 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: ...
5
votes
5answers
771 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
1answer
111 views

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

Is there an analog of Query[] in Python 3.8+?
18
votes
2answers
598 views

How to export a notebook to Jupyter?

I would like a tool to convert any Mathematica notebook into a Jupyter labs notebook, preserving as much content as possible (.ipynb files are just special json). Obviously, this would need to ...
6
votes
0answers
151 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
199 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
61 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 ...
2
votes
1answer
348 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
76 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 ...
1
vote
0answers
62 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
218 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 ...