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
1
vote
0answers
46 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
126 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
115 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
23 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 ...
2
votes
0answers
42 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 console: https://www.wolfram.com/language/12/external-system-integration/evaluate-python-in-a-notebook.html?product=...
0
votes
0answers
42 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
34 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: ...
4
votes
5answers
664 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
100 views

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

Is there an analog of Query[] in Python 3.8+?
6
votes
0answers
134 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
65 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
50 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 ...
1
vote
1answer
88 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
58 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 ...
0
votes
0answers
31 views

Unable to import local Python module to ExternalEvaluate session

Ever since upgrading to Mathematica 12, I have been unable to import a local module in Python that I need for an ExternalEvaluate session. Here is what I have that worked perfectly in Mathematica 11 ...
1
vote
0answers
26 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
142 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 ...
7
votes
2answers
322 views

How to read .npy file in Mathematica?

I have a .npy file which is created by numpy of Python as below:- ...
21
votes
1answer
949 views

How can I use the Python library networkx from Mathematica?

Is there an easy way to access the Python library networkx from Mathematica? The improvements to ExternalEvaluate in Mathematica 12.0 should make this feasible.
1
vote
0answers
61 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 ...
1
vote
0answers
27 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
61 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
148 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"]...
1
vote
0answers
155 views

Mathematica Reduce function in Sympy [closed]

I am now using Mathematica to compare two big expressions with Reduce function. However, since these two expressions are very complicated, I can not get an answer ...
0
votes
0answers
73 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? ...
3
votes
1answer
147 views

Is there any way that convert entire mathematica code to java or python?

I am novice to Mathematica. I want to convert Mathematica code from my textbook to Java or Python to trace coding.
0
votes
1answer
75 views

Convert string representation of matrix to matrix

I have a Python script which generates and outputs Mathematica matrices. I use RunProcess to run my Python script and I extract the StandardOutput which is the Mathematica matrix as a string. What I ...
1
vote
0answers
120 views

How can I ExternalEvaluate Python with tesseract?

...
1
vote
0answers
44 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 ...
0
votes
0answers
32 views

Python Syntax highlighting in external code cell [duplicate]

Mathematica has python external code cells and they execute using the available python kernel on the machine but the code cells don't have python syntax highlighting which is necessary for ...
1
vote
1answer
40 views

Using ExternalEvaluate within ParallelDo

I have had great success using Python in Mathematica (for some computations for which there are very well optimised Python packages but not for Mathematica). I have some Mathematica functions that are ...
2
votes
1answer
286 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 ...
5
votes
2answers
159 views

Using local variables in ExternalEvaluate Python

I am sure that I am missing something here, I have some larger matrices and Mathematica takes too long to compute the eigenvalues and vectors (using Eigensystem[m]) ...
1
vote
1answer
108 views

Python module attributes not recognised in ExternalEvaluate

I have Python installed and running properly. I have a file called test.py with contents c = 5 When I go to the file's ...
1
vote
1answer
160 views

Problem importing from HDF5

I'm trying to import an item from a valid HDF5 file, but I get this error: I can read the metadata, but cannot import the actual tensor dataset: And yet it's not an issue with the file's data - as ...
8
votes
2answers
360 views

How to import python pickle *.pkl?

I find some ELMo-models on github. I want to use the Simplified-Chinese version: http://pbmpb9h15.bkt.gdipper.com/zhs.model.tar.xz But these files were saved as python pickles. I want to import ...
10
votes
2answers
474 views

Mathematica equivalent of NumPy broadcast addition for large arrays [duplicate]

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition? ...
7
votes
2answers
215 views

Control a Mathematica kernel from the front-end and from python

I'd like to be able to start and control a Mathematica kernel/front-end from python and be able to evaluate things in a notebook and query results on the python side too. Is this possible?
9
votes
1answer
135 views

How to display images and plots from ExternalEvaluator?

I have a conda python 3.6 environment registered as the default ExternalEvaluator with numpy, matplotlib, cv2, and PIL installed: I'd like to show images and plot ...
5
votes
0answers
43 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
50 views

How to add new python type translation to ExternalEvaluate?

Seems like Mathematica can only import basic types (lists, numpy objects, etc). Is there a way to tell Mathematica how to understand arbitrary python objects?
3
votes
1answer
38 views

How to delete certain item(s) returned by FindExternalEvaluators[]? [duplicate]

I have tried UnregisterExternalEvaluator only to find that the item's state "Registered", changed from True to ...
4
votes
1answer
103 views

How to apply the layer of sigmoid function in neural network?

I saw an article How to build a simple neural network in 9 lines of Python code and want to reconstruct the result in Mathematica. I tried the below codes:- ...
4
votes
0answers
147 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
150 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 ...
6
votes
1answer
141 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 ...
1
vote
1answer
229 views

RunProcess works but not StartExternalSession

I'm using MMA 11.2 on Ubuntu 16.10. Any reason why RunProcess[{"python", "myscript.py"}] works, while ...
18
votes
1answer
406 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 ...
9
votes
1answer
242 views

Corresponding built-in types for Python

Where can I find the correspondence of built-in types between Mathematica and Python?
6
votes
2answers
562 views

Export a 3D array from Mathematica and import it in python as a numpy array

In ...