cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-749274%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPython%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20jsl%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20JMP%2018%EB%A1%9C%20%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-749274%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJMP%2018%EC%9D%98%20%EC%83%88%EB%A1%9C%EC%9A%B4%20Python%20%EA%B8%B0%EB%8A%A5%EC%9D%84%20%EC%9C%84%ED%95%B4%20%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%ED%95%98%EA%B3%A0%20%EC%8B%B6%EC%9D%80%20Python%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%ED%98%B8%EC%B6%9C%ED%95%98%EB%8A%94%20jsl%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EA%B0%80%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3EJMP%2018%EA%B9%8C%EC%A7%80%EB%8A%94%20Python%20%EC%97%B0%EA%B2%B0%EC%9D%84%20%EC%A4%80%EB%B9%84%ED%95%98%EA%B8%B0%20%EC%9C%84%ED%95%B4%20%EB%8B%A4%EC%9D%8C%EA%B3%BC%20%EA%B0%99%EC%9D%80%20%EC%9E%91%EC%97%85%EC%9D%84%20%EC%88%98%ED%96%89%ED%96%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F%2F%20Python%20setup%0APython%20Init(%20Debug%20Print%20Statements(%20%22TRUE%22%20)%2C%20%20Init%20Trace(%22TRUE%22)%2C%20Debug%20Print%20Output(%22TRUE%22)%20)%3B%0APython%20Submit(%0A%09%22%5C%5B%0Aimport%20numpy%20as%20_JMPnp%0Aimport%20scipy%20as%20_JMPsp%0Aimport%20pandas%20as%20_JMPpd%0Aimport%20sqlite3%20as%20_JMPsq%0Aif%20PY_DEBUG_OUTPUT%3A%0A%09print(%22Python%20Imports%20OK%22)%0A%5D%5C%22%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EPython%20Init()%EB%8A%94%20%EC%9D%B4%EC%A0%9C%20%EB%8D%94%20%EC%9D%B4%EC%83%81%20%EC%82%AC%EC%9A%A9%EB%90%98%EC%A7%80%20%EC%95%8A%EC%9C%BC%EB%AF%80%EB%A1%9C%20a)%20python%20send()%2C%20submit()%2C%20....%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0%20%EC%A0%84%EC%97%90%20Python%20%EC%97%B0%EA%B2%B0%EC%9D%84%20%EC%B4%88%EA%B8%B0%ED%99%94%ED%95%B4%EC%95%BC%20%ED%95%98%EB%8A%94%EC%A7%80%20%EA%B6%81%EA%B8%88%ED%95%A9%EB%8B%88%EB%8B%A4.%20b)%20%EA%B7%B8%EB%A0%87%EB%8B%A4%EB%A9%B4%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%ED%95%B4%EC%95%BC%20%ED%95%A0%EA%B9%8C%EC%9A%94%3F%20python%20connect()%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EA%B2%83%20%EA%B0%99%EC%95%84%EC%9A%94.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%EB%82%B4%20%ED%98%84%EC%9E%AC%20%EC%9D%B4%EB%A1%A0%EC%9D%80%20%EC%9C%84%EC%9D%98%20%EC%9A%94%EC%86%8C%EB%A5%BC%20%EB%8B%A4%EC%9D%8C%EC%9C%BC%EB%A1%9C%20%EB%8C%80%EC%B2%B4%ED%95%B4%EC%95%BC%20%ED%95%9C%EB%8B%A4%EB%8A%94%20%EA%B2%83%EC%9E%85%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EPython%20connect()%3B%0APython%20submit%20%20(%20%0A...blablabla...%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%EA%B7%B8%EB%9F%AC%EB%82%98%20%EC%9D%B4%EC%97%90%20%EB%8C%80%ED%95%9C%20%EB%AC%B8%EC%84%9C%EC%99%80%20%EC%98%88%EC%A0%9C%EB%8A%94%20%EC%95%BD%EA%B0%84%20%EB%B6%80%EC%A1%B1%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-749274%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%EC%9E%90%EB%8F%99%ED%99%94%20%EB%B0%8F%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8C%85%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-749303%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Python%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20jsl%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20JMP%2018%EB%A1%9C%20%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-749303%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJMP%2018%EC%97%90%EC%84%9C%EB%8A%94%20Python%20%ED%99%98%EA%B2%BD%EC%9D%84%20'%EC%B4%88%EA%B8%B0%ED%99%94'%ED%95%98%EB%8A%94%20%EB%8D%B0%20Python%20Init()%EB%82%98%20Python%20Connect()%EA%B0%80%20%ED%95%84%EC%9A%94%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.%20Python%EC%9D%80%20JMP%EC%97%90%20%EB%82%B4%EC%9E%A5%EB%90%98%EC%96%B4%20%EC%84%A4%EC%B9%98%EB%90%98%EB%AF%80%EB%A1%9C%20%EC%A6%89%EC%8B%9C%20%EC%82%AC%EC%9A%A9%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EC%9D%B4%EA%B2%83%EC%9D%B4%20Python%20Init()%EC%9D%B4%20%EB%8D%94%20%EC%9D%B4%EC%83%81%20%EC%82%AC%EC%9A%A9%EB%90%98%EC%A7%80%20%EC%95%8A%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EC%9E%85%EB%8B%88%EB%8B%A4.%20Python%20Connect%EB%8A%94%20%EC%97%B0%EA%B2%B0%20%EA%B0%9C%EC%B2%B4%20%EC%82%AC%EC%9A%A9%EC%9D%84%20%EC%A7%80%EC%9B%90%ED%95%98%EA%B8%B0%20%EC%9C%84%ED%95%B4%20%EC%97%AC%EC%A0%84%ED%9E%88%20%EC%A1%B4%EC%9E%AC%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3Econn%20%3D%20%ED%8C%8C%EC%9D%B4%EC%8D%AC%20%EC%97%B0%EA%B2%B0()%3B%3C%2FP%3E%0A%3CP%3Econn%20%26lt%3B%26lt%3B%20Get(%20dt%20)%3B%3C%2FP%3E%0A%3CP%3Econn%20%26lt%3B%26lt%3B%20Submit(%22%5C%5B%20...%20%ED%8C%8C%EC%9D%B4%EC%8D%AC%20%EC%BD%94%EB%93%9C%20...%20%5D%5C%22)%3B%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%EC%97%B0%EA%B2%B0%20%EA%B0%9C%EC%B2%B4%EA%B0%80%20%ED%95%84%EC%9A%94%ED%95%98%EC%A7%80%20%EC%95%8A%EC%9C%BC%EB%A9%B4%20Python%20Init()%20%EB%98%90%EB%8A%94%20Python%20Connect()%EA%B0%80%20%ED%95%84%EC%9A%94%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%8B%B9%EC%8B%A0%EC%9D%80%20%EA%B0%84%EB%8B%A8%ED%9E%88%20%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4%20%3A%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3EPython%20%EC%A0%9C%EC%B6%9C(%3C%2FP%3E%0A%3CP%3E...%20%EB%82%B4%20%EC%BD%94%EB%93%9C%EB%8A%94%20%EC%97%AC%EA%B8%B0%EC%97%90%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4%20...%3C%2FP%3E%0A%3CP%3E)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Feli
Level IV

Updating jsl scripts using Python to JMP 18

We have jsl scripts that are calling python scripts that I now want to update for the new Python functionality of JMP 18.

Up to JMP 18, we did something like this to prepare the Python connection:

// Python setup
Python Init( Debug Print Statements( "TRUE" ),  Init Trace("TRUE"), Debug Print Output("TRUE") );
Python Submit(
	"\[
import numpy as _JMPnp
import scipy as _JMPsp
import pandas as _JMPpd
import sqlite3 as _JMPsq
if PY_DEBUG_OUTPUT:
	print("Python Imports OK")
]\"
);

Since Python Init () is now deprecated, I'm wondering a) if I even need now to initialize the python connection before using python send(), submit(), .... b) if yes, how I would do it using I guess using python connect ()

 

My current theory is, that I would need to replace the element above witth: 

Python connect();
Python submit  ( 
...blablabla...
);

but the documentation and examples are a bit sparse on this.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Updating jsl scripts using Python to JMP 18

Neither the Python Init() nor the Python Connect() are necessary to 'initialize' the Python environment in JMP 18.  Because Python is built-in and installed with JMP it is available immediately.  This is why the Python Init() was deprecated.  The Python Connect still exists to support use of a connection object.

 

conn = Python Connect();

conn << Get( dt );

conn << Submit("\[ ... python code ... ]\");

 

If you don't need the connection object you do not need either Python Init() or Python Connect(). you can simply do:

 

Python Submit(

... my code here ...

);

View solution in original post

3 REPLIES 3

Re: Updating jsl scripts using Python to JMP 18

Neither the Python Init() nor the Python Connect() are necessary to 'initialize' the Python environment in JMP 18.  Because Python is built-in and installed with JMP it is available immediately.  This is why the Python Init() was deprecated.  The Python Connect still exists to support use of a connection object.

 

conn = Python Connect();

conn << Get( dt );

conn << Submit("\[ ... python code ... ]\");

 

If you don't need the connection object you do not need either Python Init() or Python Connect(). you can simply do:

 

Python Submit(

... my code here ...

);

Feli
Level IV

Re: Updating jsl scripts using Python to JMP 18

I think my error of thought was that I needed some kind of initialization because I got errors that the packages I wanted were not found.

But after running jmputils.jpip('list'), I see that I need to install them first (I was assuming that standard packages like numpy or pandas would be preinstalled).

Re: Updating jsl scripts using Python to JMP 18

JMP 18.0 only ships with the standard Python.org distribution, minus a few packages that might cause a conflict with Python running from within JMP.  Primarily this is tkinter and venv.  Any external packages need to be installed by the user.  There are a couple reasons.  Everything that JMP ships that is a 3rd-Party library, package or open source component, has to go through several approval processes internally including review by our Legal department.  It also means our watching that package for bug fix and security issues. Finally, package incompatibilities do exist, so our picking a package version means it could conflict with a package you need.  The power is in your hands to pick and choose the packages you need outside of what is shipped in the standard library.

 

Other items to note in porting JMP 14-17 Python scripts.

  • Python Term();  is unnecessary since the environment only goes away when you shut down JMP.
  • Python Get Graphics(); was removed from JMP 18. This single function caused a dependency on matplotlib. And the goal is to prevent JMP from requiring any external packages for basic functionality. It is easy enough to replicate the same functionality in your own scripts.  The Scripting Index example for 'Python Get Graphics();'  contains a complete example of the replacement code.  Simply save the figure to an image file and open the image in a JMP window.
    Python Submit("\[
    ...
    # save image to location of your choosing
    plt.savefig('/tmp/get_graphics_img.png')
    ]\");

    // plot = Python Get Graphics( png ); // DEPRECATED plot = Open( "/tmp/get_graphics_img.png", png ); pngJMP = New Window( "Plot", Picture Box( plot ) ); Python Submit( "plt.close()" ); rc = Delete File( "/tmp/get_graphics_img.png" );
  • Python Control() was used for setting some options with matplotlib.  While not removed in 18.0, its only function now is to print a 'deprecated' warning to the log.
  • Python Is Connected(); is deprecated because it always returns true.  The Python environment is always available.

One last issues to note. We discovered an issue with mx = Python Get( numpy.ndarray );  If the NumPy array was greater than 2 dimensions you would get a result, but it would lose dimensions greater than two.  There was also an issue if the NumPy array's memory layout was Column-Major (Fortran style) rather than Row-Major( C style ).  This could result in a JMP crash.  This issue has been resolved. The fix will be present in JMP 18.1.  If you run into this in JMP 18.0, make sure your NumPy data is in Row-Major format and 'Get' only 1 or 2 Dimension ndarrays.   When you Get() a ndarray it tries to create a JSL Matrix which only supports either 1 or 2 dimensions. This bug is specific to JMP 18.0, since JMP 14-17 transferred the data through the file system as temporary binary file of doubles.  Though 14-17 might loose data if number of dimensions is greater than 2.