cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
neelsrejan
Level III

JMP 18 python pptx import not seeming to work

Hi all, 

 

My company has just got the JMP 18 license and the PowerPoint automation is not working anymore due to the dependencies. From JMP documentation I have understood that python is now an integrated version in which case dependencies have to be installed through jmputils. Below is the code I have so far for the imports the powerpoint used to use. I am still getting the same error even with the dependencies looking updated through the list command. 

 

scr = Python Execute(
	{}, 
	{}, 
	"\[
import jmp
import jmputils

jmputils.jpip('list')
jmputils.jpip('install --upgrade', 'pip setuptools python-pptx')
from pptx import Presentation #Problem Line from pptx.util import Inches from pptx.dml.color import RGBColor from datetime import date ]\" );

Here is the log error I am receiving:

 

neelsrejan_0-1721096400037.png

Due to this I am not able to create and save the presentation. Any help would be greatly appreciated. Thanks!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: JMP 18 python pptx import not seeming to work

import jmp
from jmputils import jpip

jpip('list')
jpip('install --upgrade', 'pip setuptools python-pptx')

The result I get in running the above is:

Requirement already satisfied: pip in c:\users\_myUSERID_\appdata\roaming\jmp\jmp\python\python311\site-packages (24.0)
Collecting pip
  Downloading pip-24.1.2-py3-none-any.whl.metadata (3.6 kB)
Requirement already satisfied: setuptools in c:\users\_myUSERID_\appdata\roaming\jmp\jmp\python\python311\site-packages (70.0.0)
Collecting setuptools
  Downloading setuptools-70.3.0-py3-none-any.whl.metadata (5.8 kB)
Collecting python-pptx
  Downloading python_pptx-0.6.23-py3-none-any.whl.metadata (18 kB)
Collecting lxml>=3.1.0 (from python-pptx)
  Downloading lxml-5.2.2-cp311-cp311-win_amd64.whl.metadata (3.5 kB)
Collecting Pillow>=3.3.2 (from python-pptx)
  Downloading pillow-10.4.0-cp311-cp311-win_amd64.whl.metadata (9.3 kB)
Collecting XlsxWriter>=0.5.7 (from python-pptx)
  Downloading XlsxWriter-3.2.0-py3-none-any.whl.metadata (2.6 kB)
Downloading pip-24.1.2-py3-none-any.whl (1.8 MB)
   ---------------------------------------- 1.8/1.8 MB 8.3 MB/s eta 0:00:00
Downloading setuptools-70.3.0-py3-none-any.whl (931 kB)
   ---------------------------------------- 931.1/931.1 kB 4.9 MB/s eta 0:00:00
Downloading python_pptx-0.6.23-py3-none-any.whl (471 kB)
   ---------------------------------------- 471.6/471.6 kB 5.0 MB/s eta 0:00:00
Downloading lxml-5.2.2-cp311-cp311-win_amd64.whl (3.8 MB)
   ---------------------------------------- 3.8/3.8 MB 8.1 MB/s eta 0:00:00
Downloading pillow-10.4.0-cp311-cp311-win_amd64.whl (2.6 MB)
   ---------------------------------------- 2.6/2.6 MB 9.1 MB/s eta 0:00:00
Downloading XlsxWriter-3.2.0-py3-none-any.whl (159 kB)
   ---------------------------------------- 159.9/159.9 kB 3.2 MB/s eta 0:00:00
Installing collected packages: XlsxWriter, setuptools, pip, Pillow, lxml, python-pptx
  Attempting uninstall: setuptools
    Found existing installation: setuptools 70.0.0
    Uninstalling setuptools-70.0.0:
      Successfully uninstalled setuptools-70.0.0
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
Successfully installed Pillow-10.4.0 XlsxWriter-3.2.0 lxml-5.2.2 pip-24.1.2 python-pptx-0.6.23 setuptools-70.3.0

At which point  

from pptx import Presentation

Gives in the log

//:*/
from pptx import Presentation
/*:

I would look into the log and investigate what you see in the log when you run:

jmputils.jpip('install --upgrade', 'python-pptx')

I feel you must have had some issue that occurred when installing the package, that should be reported in the log.  Ir could be permissions; to access the internet, it could be disk permissions, it could be lack of disk space, ... Without knowing what jpip reported to log it's kind of hard to track down.  I tried the above with 18.1.0 and had no issues.  Have you tried shutting down JMP and restarting?  I had no issues installing or running your script. Since all we are running here is Python code, I ran it directly from a Python script window, rather than Python Submit() or Python Execute() from JSL. JSL's Pyrthon Install Packages("python-pptx") should also work.  Under the hood it calls jmputils.jpip().  You can also drop down to the terminal level to install packages.  Use Python Create JPIP CMD(); to create a tailored command line jpip.bat or jpip shell script (macOS) which is customized to your JMP environment. Running the command launches a dialog picker to choose the destination directory for saving the jpip script. From cmd window / Terminal  run

c:\path_you_chose\jpip.bat install python-pptx

 

View solution in original post

Re: JMP 18 python pptx import not seeming to work

Should have mentioned right up front restarting JMP.  That was one of the early fixes since JMP 18.0.  On first launch, the site-packages directory hasn't been established until it's necessary.  But Python doesn't recognize any packages added if the site-packages directory is created after Python Initialization.  Once it's established, you can add new packages and the JMP Python integration should see them immediately.  That has been fixed in the JMP 19 development branch because JMP itself establishes the site-packages directory before Python initialization.  It's a large enough of a code change that it isn't in the 18 branch. 

View solution in original post

5 REPLIES 5
jthi
Super User

Re: JMP 18 python pptx import not seeming to work

There are many ways of installing Python packages in JMP18 (Install Python Packages using JSL (jmp.com)). Were there any errors during the package installation? Can you use jpip to install other packages? For me running your code seemed to work fine. The packages should be installed to your JMP Python user directory, you can find that by running following python command in JMP

 

import jmp
print(jmp.PY_USER_APPDIR)

 

 

Tagging @Paul_Nelson as he most likely has more ideas what could be wrong.

-Jarmo

Re: JMP 18 python pptx import not seeming to work

import jmp
from jmputils import jpip

jpip('list')
jpip('install --upgrade', 'pip setuptools python-pptx')

The result I get in running the above is:

Requirement already satisfied: pip in c:\users\_myUSERID_\appdata\roaming\jmp\jmp\python\python311\site-packages (24.0)
Collecting pip
  Downloading pip-24.1.2-py3-none-any.whl.metadata (3.6 kB)
Requirement already satisfied: setuptools in c:\users\_myUSERID_\appdata\roaming\jmp\jmp\python\python311\site-packages (70.0.0)
Collecting setuptools
  Downloading setuptools-70.3.0-py3-none-any.whl.metadata (5.8 kB)
Collecting python-pptx
  Downloading python_pptx-0.6.23-py3-none-any.whl.metadata (18 kB)
Collecting lxml>=3.1.0 (from python-pptx)
  Downloading lxml-5.2.2-cp311-cp311-win_amd64.whl.metadata (3.5 kB)
Collecting Pillow>=3.3.2 (from python-pptx)
  Downloading pillow-10.4.0-cp311-cp311-win_amd64.whl.metadata (9.3 kB)
Collecting XlsxWriter>=0.5.7 (from python-pptx)
  Downloading XlsxWriter-3.2.0-py3-none-any.whl.metadata (2.6 kB)
Downloading pip-24.1.2-py3-none-any.whl (1.8 MB)
   ---------------------------------------- 1.8/1.8 MB 8.3 MB/s eta 0:00:00
Downloading setuptools-70.3.0-py3-none-any.whl (931 kB)
   ---------------------------------------- 931.1/931.1 kB 4.9 MB/s eta 0:00:00
Downloading python_pptx-0.6.23-py3-none-any.whl (471 kB)
   ---------------------------------------- 471.6/471.6 kB 5.0 MB/s eta 0:00:00
Downloading lxml-5.2.2-cp311-cp311-win_amd64.whl (3.8 MB)
   ---------------------------------------- 3.8/3.8 MB 8.1 MB/s eta 0:00:00
Downloading pillow-10.4.0-cp311-cp311-win_amd64.whl (2.6 MB)
   ---------------------------------------- 2.6/2.6 MB 9.1 MB/s eta 0:00:00
Downloading XlsxWriter-3.2.0-py3-none-any.whl (159 kB)
   ---------------------------------------- 159.9/159.9 kB 3.2 MB/s eta 0:00:00
Installing collected packages: XlsxWriter, setuptools, pip, Pillow, lxml, python-pptx
  Attempting uninstall: setuptools
    Found existing installation: setuptools 70.0.0
    Uninstalling setuptools-70.0.0:
      Successfully uninstalled setuptools-70.0.0
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
Successfully installed Pillow-10.4.0 XlsxWriter-3.2.0 lxml-5.2.2 pip-24.1.2 python-pptx-0.6.23 setuptools-70.3.0

At which point  

from pptx import Presentation

Gives in the log

//:*/
from pptx import Presentation
/*:

I would look into the log and investigate what you see in the log when you run:

jmputils.jpip('install --upgrade', 'python-pptx')

I feel you must have had some issue that occurred when installing the package, that should be reported in the log.  Ir could be permissions; to access the internet, it could be disk permissions, it could be lack of disk space, ... Without knowing what jpip reported to log it's kind of hard to track down.  I tried the above with 18.1.0 and had no issues.  Have you tried shutting down JMP and restarting?  I had no issues installing or running your script. Since all we are running here is Python code, I ran it directly from a Python script window, rather than Python Submit() or Python Execute() from JSL. JSL's Pyrthon Install Packages("python-pptx") should also work.  Under the hood it calls jmputils.jpip().  You can also drop down to the terminal level to install packages.  Use Python Create JPIP CMD(); to create a tailored command line jpip.bat or jpip shell script (macOS) which is customized to your JMP environment. Running the command launches a dialog picker to choose the destination directory for saving the jpip script. From cmd window / Terminal  run

c:\path_you_chose\jpip.bat install python-pptx

 

neelsrejan
Level III

Re: JMP 18 python pptx import not seeming to work

Hi Paul, 

 

I restarted JMP and the code I provided worked interestingly enough. I appreciate the detailed description and additional steps I could use to troubleshoot if I need in the future. Thank you!

Re: JMP 18 python pptx import not seeming to work

Should have mentioned right up front restarting JMP.  That was one of the early fixes since JMP 18.0.  On first launch, the site-packages directory hasn't been established until it's necessary.  But Python doesn't recognize any packages added if the site-packages directory is created after Python Initialization.  Once it's established, you can add new packages and the JMP Python integration should see them immediately.  That has been fixed in the JMP 19 development branch because JMP itself establishes the site-packages directory before Python initialization.  It's a large enough of a code change that it isn't in the 18 branch. 

neelsrejan
Level III

Re: JMP 18 python pptx import not seeming to work

Hi Jarmo, 

 

Thanks for the initial help and reaching out to Paul, I appreciate the help!