Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
4 views

How to create heatmap over an image using coordinate points? [migrated]

I have an image of size 1024 x1024. I have probability values of some areas and coordinate points. How can I write a code for heatmap generation using the coordinate points and probability values over ...
0
votes
0answers
13 views

numpy.linalg.solve returns a solution for a matrix that is not full rank [migrated]

I've been learning the basics of OLS regression, and was told that there can't be perfect multicolinearity in the model. I have a matrix that is obviously not of full rank: ...
0
votes
0answers
16 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
26 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
40 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
75 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
41 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
106 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
44 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
64 views
1
vote
0answers
40 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
24 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
34 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
118 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
104 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
72 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
113 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 ...
9
votes
2answers
223 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
444 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
136 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
121 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
34 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
45 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
33 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
78 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:- ...
3
votes
0answers
118 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
127 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
104 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 ...
0
votes
1answer
166 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 ...
5
votes
0answers
199 views

connect to Python kernel started by Jupyter

As Mathematica has the interoperability with Python since ver. 11.2, is it possible to connect the Python kernels started by Jupyter from Mathematica? Can someone provide a pathway for doing that? ...
9
votes
1answer
235 views

Corresponding built-in types for Python

Where can I find the correspondence of built-in types between Mathematica and Python?
4
votes
3answers
457 views

Difference between Python and Mathematica for Newton's Algorithm [closed]

I was about to study the roots of the function defined below, using Newton's Method: 9 Exp[-x] Sin[2 π x] - 0.0015 For initial values, I have: ...
3
votes
0answers
110 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
145 views

Mathematica style plotting in Python? [duplicate]

This question has two related parts. I recently started using more python because it is easier to setup remote machines (and cheaper). But I really miss Mathematica's plotting capabilities and syntax. ...
7
votes
0answers
108 views

How to pass in-memory images through ExternalEvaluate?

Version 11.2 has a new import/export format PythonExpression. Unfortunately, it doesn't work out-of-the-box with images: And using the ImageData directly is too slow: Anyhow, I have some image ...
19
votes
1answer
605 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 ...
4
votes
1answer
153 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 ...
5
votes
1answer
827 views

Equivalent of “for X in [list]” or “foreach”

In Python, we can evaluate an expression over specific values of x in a list. Example: ...
4
votes
3answers
694 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 ...
1
vote
0answers
68 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 ...
4
votes
1answer
488 views

Problem calling Python scripts from Mathematica

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script. I have a script my_script.py ...
0
votes
2answers
506 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 ...
27
votes
2answers
2k views

Exchanging numpy arrays between Python and Mathematica?

I've been using np.savetxt(location, result, delimiter=',') in Python followed by Import[location,"CSV"] in Mathematica. Some of ...
7
votes
1answer
376 views

mathematica's equivalent of python list functionnality

In Python there is a a compact syntax for creating variables that refer to the various list elements. ...
3
votes
1answer
554 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 ...
7
votes
4answers
528 views

Python's “pop” equivalent in Mathematica

I will like to know if there is an equivalent to python's pop method, here is how it's done in Python: ...
5
votes
2answers
470 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 ...
0
votes
1answer
1k views

Help: Shifted columns values of a dataset [closed]

How do i add a new column to a Dataset that is the shifted version of another column with nulls placed in missing places. (just like the function shift in pandas in ...
4
votes
2answers
254 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 ...