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
0
votes
0answers
9 views

How to extract coefficients from multiple equations and store it in a matrix in numpy [migrated]

I’ve built a function which produces linear equations for values of i in range(1,4). I want to know if there are any inbuilt (or other) functions to extract coefficients from these equations and store ...
0
votes
0answers
27 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
7 views

Count values of sublists [migrated]

Let's say I have a list in Pythong like below with each sublist representing a day with and how many which products are available in a shop: ...
21
votes
2answers
1k views

ExternalEvaluate for Python fails with Import::nopythonevals

I tried using ExternalEvaluate on OS X with Anaconda Python, and every ExternalEvaluate call failed with the ...
2
votes
1answer
42 views

WolframClient Converting Output Of Solve To Sympy

I'm trying to convert the output of WolframClient to Python. Here's a toy example: ...
1
vote
1answer
60 views

Periodic Boundary Condition for a List

Please take attention to a list as: data={6,12,5,8}; It may be interesting in Python if i=0, then ...
0
votes
1answer
53 views

How to find a numerical solution for a differential equation with constraints?

I want first to apologize for my poor english level ^^ Let me present my issue. I want resolve numerically (I use Python) for x in [0;1] the following differential equation : $$dy/dx = a(y - y^2) $$ ...
4
votes
2answers
76 views

Wolfram Client Library: Cannot establish connection with Kernel in second Python function

I have recently started using the Wolfram Client Library (WCL) for Python in my Linux machine in order to automate running a Mathematica notebook many times. I have an Anaconda environment ...
5
votes
1answer
201 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 ...
7
votes
2answers
80 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. ...
10
votes
2answers
832 views

How to get Python bindings to work on the Raspberry Pi

There are several examples on this site on how to call Mathematica from Python. You can: install the bindings that come with Mathematica; or call a script as a subprocess from within Python; or ...
0
votes
1answer
115 views

Adopt Mathematica codes for circumscribed and inscribed ellipsoids to related sets

Users Daniel Huber and Dominic have provided an interesting answer each to the question JohnEllipsoids of constructing circumscribing and inscribing ellipsoids for a certain three-dimensional convex ...
0
votes
0answers
60 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 ...
1
vote
1answer
38 views

External evaluations — selecting one of several Python versions

I have several Python versions installed and registered to Mathematica: FindExternalEvaluators["Python"] When I run the following code which one of ...
2
votes
1answer
90 views

How to run Python script with an argument?

I want to run Python script with argument 'arg' > python app.py arg Without 'arg' it works like ...
0
votes
1answer
58 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
1answer
33 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
40 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), ...
3
votes
1answer
92 views

Issue while evaluating Mathematica expressions from Python [closed]

This is a follow up to my question posted here I am trying to run the code posted here as an answer in the above-mentioned link here from Python I tried, ...
0
votes
1answer
62 views

Problem while running Mathematica code from Python using wolframclient library

This is a follow up to my previous post here I am trying to run a function from Python using wolframclient. The input arguments are passed from Python as Python ...
1
vote
0answers
46 views
2
votes
3answers
190 views

How to use Mathematica from Python

I've been using the following lines of code to generate 3D geometry (ref). The inputs edges, vd, ...
69
votes
6answers
29k views

How to use Mathematica functions in Python programs?

I'd like to know how can I call Mathematica functions from Python. I appreciate a example, for example, using the Mathematica function Prime. I had search about MathLink but how to use it in Python ...
5
votes
2answers
375 views

How to assemble Python abstract syntax trees (AST) in Mathematica?

I would like to assemble Python 'ast.Module' objects inside of Mathematica and then submit them to Python via e.g. ExternalEvaluate["exec(astObject)"]. ...
11
votes
3answers
212 views

Is it possible to call back to Mathematica when using Python through ExternalEvaluate?

ExternalEvaluate makes it possible to call Python code from Mathematica. The Wolfram Client for Python makes it possible to call Mathematica from Python. When using ...
3
votes
1answer
86 views

How to use Python's input() with External Evaluation?

I want to use input() in Python code which runs in the Wolfram Notebook. So I create an external evaluation cell by typing ">" and choosing Python. Then I define this function: ...
13
votes
3answers
14k views
5
votes
1answer
127 views

Binary file that can be read by both, Mathematica and Python

I would like to analyze data set in both Matematica and Python. What is a time and size efficient format to store the data?
2
votes
1answer
107 views

FindExternalEvaluators['Python"] returns a blank box instead of the locations or python versions

I'm using Mathematica 12.0 Student Edition and have python 3.7.6 instilled in anaconda and 3.7.8 installed via Microsoft Store. I have followed the reference instructions here but to no avail. The ...
3
votes
1answer
167 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:...
14
votes
1answer
190 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
85 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
2answers
1k views

Create smooth colour map from given array for ListPlot3D

I am trying to find the Mathematica equivalent for Python Matplotlib's cmap option, to be used with ListPlot3D[]. Here is the ...
0
votes
0answers
73 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 ...
49
votes
3answers
28k 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 ...
2
votes
0answers
83 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
60 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
104 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....
6
votes
0answers
201 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
144 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 ...
-2
votes
2answers
140 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 ...
4
votes
2answers
635 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 ...
3
votes
0answers
31 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 <...
8
votes
1answer
116 views

Dynamically access variables in external session?

I tried to get a value from a python session to show up in a dynamic cell: First run: ...
3
votes
0answers
72 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=...
3
votes
2answers
186 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 ...
2
votes
0answers
29 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
0answers
47 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"...