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
35
votes
2answers
3k views

Is there a built-in equivalent to Python's enumerate?

Python's built-in function enumerate takes an iterable over $(a_0, a_1, \dots )$ as argument and returns an iterable over the sequence of pairs $((0, a_0), (1, a_1),...
64
votes
6answers
27k 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 ...
55
votes
6answers
9k views

Is there a way to run Python from within Mathematica?

I know there is some support for running Mathematica from Python, but is there any way to do the reverse. For example, to import some Python classes and use them in Mathematica?
31
votes
3answers
2k views

Calling IronPython code from Mathematica

I'd like to call some IronPython code from Mathematica using .NET/Link. The problem is that the code lives in .py files, yet from Mathematica I can only load .NET assemblies which are DLLs. So it ...
19
votes
2answers
4k views

Prepare mathematica output to be parsed in Python

I have Mathematica output that I would like to parse in python so I can generate equivalent expressions. So suppose I have the following: ...
64
votes
3answers
5k views

Python-style plots in Mathematica

I love making plots in Mathematica. And I love to spend a lot of time making high-quality plots that maximize readability and aesthetics. For most cases, Mathematica can make very beautiful images, ...
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 ...
20
votes
1answer
809 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 ...
6
votes
1answer
166 views

FindExternalEvaluators[“Python”] gives me an uninstalled version of Python

Long time ago, I have two versions of python installed in my pc, and I registered them all in mathematica. Later I uninstalled one of them, but ...
5
votes
1answer
134 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 (...
4
votes
3answers
875 views

run python with package numpy in mathematica

For example, if I have a python script called simple.py contains as simple as a=1 print(a) then ...
2
votes
1answer
144 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 *) ...
4
votes
2answers
284 views

How to call Picture Bed API

I want to call this Picture bed API to upload my picture and return its link.I have translated the official instructional the page into English.And there is a example succeed to use it with Python. I ...
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, ...
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 ...
10
votes
1answer
765 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 ...
9
votes
2answers
11k views

Convert mathematica math expression form to python math expression?

I obtain a raw input form of: ...
6
votes
2answers
2k views

How to export an output matrix obtained in mathematica to a matrix in python with the correct format?

I have a large sparse matrix as the output and I want to save the output and open it as a matrix in python. The output is a 6000 x 6000 matrix and I don't know how to make changes to the file such ...
18
votes
5answers
3k views

List comprehension in Mathematica

Python supports a concept called "list comprehensions". Following is sample example (written in Python syntax) ...
5
votes
1answer
216 views

Using virtualenv and ExternalEvaluate

When doing development work with python, it's often recommended that one use virtualenv. It provides an environment separate from one's standard python evaluator. Now that 11.2 has support for simple ...
10
votes
1answer
2k views

Output from Wolfram language in Python

I have a Python program which will run a script in the Wolfram language and then return to the main program. Is it possible to return values/variables to the main program? This is the code in Python ...
5
votes
3answers
3k views

How to convert a Mathematica list in a Python list?

I was wondering if you know, how to save a Mathematica list (variable) such that it can be read later in Python. In order words, how to save a variable ...
5
votes
0answers
54 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
2answers
573 views

Convert Python math expression form (Sin and Cos) to Python math expression?

I have a really big symbolic output from Python, and it contains Sin and Cos. Now I want to solve it using Mathematica, but the ...
3
votes
1answer
717 views

Python/Numpy array manipulation in Mathematica syntax

As a python programmer, numpy tools usually come to my mind if I want to manipulate arrays (list, matrices, ...). Is there any reference (e.g., dictionary) of how to translate numpy syntax to ...