cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
pmroz
Super User

How to configure Python for JMP 14?

I'm very new to Python so this is hopefully an easy question.  I have Python version 3.6 and 3.7 installed.  I installed numpy, matplotlib, scipy and pdfkit in both versions.  However I get errors in the log window when trying to run examples from the scripting index.

For the Python Get example:

Names Default To Here( 1 );
Python Init();
x1 = [1, 2, 3];
Python Send( x1 );
x2 = Python Get( x1 );
Show( x1, x2 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt1 );
dt2 = Python Get( dt1 );
dt2 << New Data View;
Close( dt1 );
Python Term();

I get the following errors:

//:*/
Names Default To Here( 1 );
Python Init();
x1 = [1, 2, 3];
Python Send( x1 );
x2 = Python Get( x1 );
Show( x1, x2 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt1 );
dt2 = Python Get( dt1 );
dt2 << New Data View;
Close( dt1 );
Python Term();
/*:

/**********/
# Read a binary file containing doubles into an ndarray
x1 = _JMPnp.fromfile("C:\\Users\\pmroz\\AppData\\Local\\Temp\\eacac6a7-dd5e-4ceb-dcbd0248455fb787.csv", dtype=_JMPnp.float64, count=-1, sep="")
/**********/
Traceback (most recent call last):
  File "<string>", line 2, in <module>
NameError: name '_JMPnp' is not defined

x1 = [1, 2, 3];
x2 = .;
/**********/
# Import a JMP exported .csv file into a Data Frame
dt1 = _JMPpd.read_csv("C:\\Users\\pmroz\\AppData\\Local\\Temp\\8b6475be-aaf0-408b-d1cae4522f253881.csv")
/**********/
Traceback (most recent call last):
  File "<string>", line 2, in <module>
NameError: name '_JMPpd' is not defined

Send Expects Scriptable Object in access or evaluation of 'Send' , dt2 <<  /*###*/New Data View/*###*/

In the following script, error marked by /*###*/
Names Default To Here( 1 );
Python Init();
x1 = [1, 2, 3];
Python Send( x1 );
x2 = Python Get( x1 );
Show( x1, x2 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt1 );
dt2 = Python Get( dt1 );
dt2 <<  /*###*/New Data View/*###*/;
Close( dt1 );
Python Term();

What am I missing?  Thanks.

13 REPLIES 13
GM1
GM1
Level I

Re: How to configure Python for JMP 14?

Hi Paul,

I already got it to work (at least on one PC, on the other it there is an error when I want to import numpy). I wanted to suggest that, when you work on this topic, you could set it up in a way which allows to choose easily between different Conda environments.

 

Is the problem with the transfer of the Data Table to pandas a known issue or am I doing something wrong?

 

Thanks

Gerd

bjbreitling
Level IV

Re: How to configure Python for JMP 14?

Hi Paul,

 

How do you actually see anything you wubmit to python in python from a JSL file? I dont have any experience doing this but when I send x1 as the example you have and I go to a python scripting window x1 isn't stored. Do you have some kind of step by step documentation on this?

Re: How to configure Python for JMP 14?

There a couple things going on here to make use of JMP and Python.

1. JMP has a scripting language and log for JSL.
* Seeing values in JSL, you can evaluate them and see them in the log, you can create or put them in data tables, you can put them in databases or even draw graphic output yourself.
* You can write values to a file.
2. Python is it’s own environment, a and b above hold true in python as well, but by using python statements and programs. Just like JSL’s show displays a JSL value, python’s print( ) statement will print a python variable.
In the Python Send() example in the scripting guide


Names Default To Here( 1 );
Python Init();
x = [1, 2, 3];
Python Send( x );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt );
Close( dt );
Python Submit( "print(x)" );
Python Submit( "print(dt)" );
Python Term();


The Python Submit (“print(x)”); // is executing the python code (“print(x)”) and printing the value of x as seen by Python, it is a separate variable from the JSL x. and until the Python Send(x) there is no variable x on the Python side, only the JSL x

So if by example the above code was

Names Default To Here( 1 );
Python Init();
x = [1, 2, 3];
Python Send( x );
x = [3,2,1];
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt );
Close( dt );
Python Submit( "print(x)" );
Python Submit( "print(dt)" );
Python Term();
Show( x );



You will get from the Python Submit(“print(x)”) the x being 1, 2 ,3
But from the Show (x);
You would get the 3, 2, 1 you have to remember you operating across two different scripting environments.

I would suggest you get familiar with exploring the capabilities of JSL without python, there are tons of JSL samples and lots of materials to understand working with JSL. And, exploring programming in Python outside of JMP again there are examples too numerous to count on the internet including tutorial sites. Having good familiarity with each, will give you insight into the strengths and weaknesses of each language. Because you need to decide where you want to do which computations. You can do everything in python, passing only initial data and returning results, or you can do most everything in JSL, calling out to python to do some computation or processing that’s easier to accomplish in Python than JSL, or any mix in between.

Paul

ananyagupta
Level I

Re: How to configure Python for JMP 14?

Hi, I also started to learn Python from CETPA INFOTECH. I have not much knowledge yet but whatever I know and used I share here :
Follow the link to download the zipped source code available for Unix/Linux.
Download and extract files.
Editing the Modules/Setup file if you want to customize some options.
run ./configure script.
make.
make install.
After reading Paul answer I understand briefly and I agree with his solution.