cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
1026
Level I

About the Python and JMP interactive issues

hi all experts

there are two issues that I  learn the Python and JMP interactive in JMP 16.2

 

Q1: 

 

Names Default To Here( 1 );
Python Init( Echo( 1));

z ="python test";
Python Send( z,P );

Python Submit( "print(P)" );
Python Submit( "print(z)" );

 

 it's output  context: 

/**********/
print(P)
/**********/


/**********/
print(z)
/**********/
python test

0

 

which means that Python don't receive the P parameter equaling to z , so anyting wrong?

Q2:

 

Names Default To Here( 1 );
Python Init( Echo( 1));
x1 = [1, 2, 3];
Python Send( x1, P_x );
Python Submit( "print(P_x)" );
Python Submit( "print(x1)" );
x2 = Python Get(  x1 );
Show( x1, x2 );

But it's output context: 

 

/**********/
print(P_x)
/**********/


/**********/
print(x1)
/**********/


x1 = [1, 2, 3];
x2 = .;

 

Besides Q1 and this code even can't normally output the list vale in Log ? Is this a bug for list value transfer between Python and JMP?

5 REPLIES 5
txnelson
Super User

Re: About the Python and JMP interactive issues

Welcome to the Community Discussion forum.

Concerning your 1st question, I do not see anything in error.  When you Send scalar values to Python, and one of them, P does not exist in JMP, it can not pass anything to Python.  Therefore, Python not displaying any value with:

print(P)

has nothing to display.

Concerning your Q2.  Using JMP 16.2 on a Windows 11 pc, I receive the following output

 

/**********/
print(P_x)
/**********/
/**********/
print(x1)
/**********/
[[1.]
 [2.]
 [3.]]

x1 = [1, 2, 3];
x2 = [1, 2, 3];

Which is exactly what I would expect.  The code works the same on JMP 17

Jim
1026
Level I

Re: About the Python and JMP interactive issues

thanks for your support and i think i konw what happen to my JMP, because i just reinstal my computer OS from WIN10 to WIN 11, which  may lost some key environment for JMP, issue is fixed but another issue happend : 

// This is the Scripts manual code for Python Get
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();

it's output is shown as below:

 

x1 = [1, 2, 3];
x2 = [1, 2, 3];
Send Expects Scriptable Object in access or evaluation of 'Send' , dt2 << /*###*/New Data View/*###*/

at line 10 in Scripting Index

 

i get the type of dt2 is Number :  Type(dt2) = "Number";, so is there any solution for  this issue?

1026
Level I

Re: About the Python and JMP interactive issues

sorry, i just forget to install the packages for Python, issue is fixed

Craige_Hales
Super User

Re: About the Python and JMP interactive issues

Names Default To Here( 1 );
Python Init();
x = [1, 2, 3];
Python Send( x,Python Name("y") ); // the python name seems to be a string
Python Submit( "print(y)" );
Python Term();

I think you might prefer to use it the way I did in Browser Scripting with Python Selenium .

  • PythonExecute( { input }, { output }, " python code using input and producing output " )
  • try: ... except ... around the python code
  • return a string for the return code, notice repr(e) to get a string from the exception
  • check both the return code from PythonExecute AND the string return code, they are for different errors

JMP is not currently doing a great job of handling errors in the python script; the try-except will make your work a lot more fun.

Craige
1026
Level I

Re: About the Python and JMP interactive issues

thanks for your answer