cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Zach_Eyde
Level I

JMP 18 creating exe from python code using pyinstaller

All,

 

I havent seen this question asked, but if I make an application using JMP 18 embedded python, can I leverage Pyinstaller to make an executable so other user can also use the application without needing JMP18 or installing all the python packages?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JMP 18 creating exe from python code using pyinstaller

Even with a normal standalone Python environment, you need for the user to install packages that your code will depend on.  Your scripts can install the packages using either Python or JSL. See the scripting Index for documentation of JSL's Python Install Packages( ), and import jmputils's jpip()

 

You can wrap the import statement with a try: except: block to catch the error if an import fails, and in the except: block do the jmputils.jpip() install of the package.  But remember at this point Python already tried, so in the except block after the install you will also need importlib and make a reload() on of the import module in question.

 

 

I believe the best way is to create a real Python package for your Python code, complete with a project.toml file that sets up all the dependencies so that you can then do a jpip('install', 'your_package')   Host that on PyPi, your own repository or just a path in your filesystem to the package.  See regular Python packaging guidelines on how to create Python packages. Then pip, via jpip, takes care of pulling in all of the dependencies.

View solution in original post

5 REPLIES 5
jthi
Super User

Re: JMP 18 creating exe from python code using pyinstaller

It might be possible but you wouldn't be able to use any of the JMP features that way (jmp package or anything it offers) and in that case I would just create a separate virtual environment for that code and manage it that way (so run Python outside of JMP).

-Jarmo
Zach_Eyde
Level I

Re: JMP 18 creating exe from python code using pyinstaller

Thanks Jarmo for the response. Is there any way (via addin maybe?) to share an application without needing to install all the python packages in the end-user JMP18?

Re: JMP 18 creating exe from python code using pyinstaller

Even with a normal standalone Python environment, you need for the user to install packages that your code will depend on.  Your scripts can install the packages using either Python or JSL. See the scripting Index for documentation of JSL's Python Install Packages( ), and import jmputils's jpip()

 

You can wrap the import statement with a try: except: block to catch the error if an import fails, and in the except: block do the jmputils.jpip() install of the package.  But remember at this point Python already tried, so in the except block after the install you will also need importlib and make a reload() on of the import module in question.

 

 

I believe the best way is to create a real Python package for your Python code, complete with a project.toml file that sets up all the dependencies so that you can then do a jpip('install', 'your_package')   Host that on PyPi, your own repository or just a path in your filesystem to the package.  See regular Python packaging guidelines on how to create Python packages. Then pip, via jpip, takes care of pulling in all of the dependencies.

Re: JMP 18 creating exe from python code using pyinstaller

Python's importlib has all kinds of capabilities available see the Python documentation on importlib. 

https://docs.python.org/3.11/library/importlib.html

Zach_Eyde
Level I

Re: JMP 18 creating exe from python code using pyinstaller

Hey Paul,

 

I think I can use python package pipreqs to create a requirements.txt for only the packages used in the application. Then I should be able to "jpip pip install -r requirements.txt" to installed all required packages. 1 question for you:

 

Can you add a jpip.bat file to the addin additional files, move to the JMP 18 directory path to utilize jpip function or do i need to create each users individual jpip.bat file on the end-user machine.