cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
zetaVagabond1
Level III

No Module named 'pandas'

I’m running a JSL script in JMP 18 that uses Python. On macOS everything works fine, but on Windows I get this error:

Traceback (most recent call last):
  File "<string>", line 7, in <module>
ModuleNotFoundError: No module named 'pandas'

In the embedded log is see following:
Creating: C:\\Users\\Admin\\AppData\\Roaming\\JMP\\JMP\\Python\\Python311\\site-packages
This tells me that JMP 18 doesn't install python automatically. Is there a pre-requisite for python be installed?

I am also trying to install this way to ensure the script doesn't fail irrespective of the system:
Python Submit("
import jmputils
required_packages = ['pandas', 'numpy']

# get list of installed python packages
installed = jmputils.jpip('list')

# check & install missing packages
for pkg in required_packages:
    if pkg.lower() not in [p.lower() for p in installed]:
        print(f'{pkg} not installed — installing...')
        jmputils.jpip('install', pkg)
    else:
        print(f'{pkg} is already installed.')

jmputils.jpip('list')

");
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: No Module named 'pandas'

To my knowledge, in JMP18 that folder gets added when Python is "run" first time and you can most maybe force it by running something like 

Python Submit("import jmp");

in JMP Script Editor

-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: No Module named 'pandas'

To my knowledge, in JMP18 that folder gets added when Python is "run" first time and you can most maybe force it by running something like 

Python Submit("import jmp");

in JMP Script Editor

-Jarmo
hogi
Level XIII

Re: No Module named 'pandas'

An error message from Python is a clear sign that python is installed ; )

to install Python packages from JSL, please use:

Python Install Packages( "numpy pandas" );

hogi_0-1763651182279.png

 

zetaVagabond1
Level III

Re: No Module named 'pandas'

Thanks, yes it created the python directory and few packages. below:

Python Submit("
import jmputils

required = ['pandas', 'numpy']

# Get installed packages safely
installed = jmputils.jpip('list')
if installed is None:
    installed = []

print('Installed packages:', installed)

# Install missing ones
for pkg in required:
    if pkg.lower() not in [p.lower() for p in installed]:
        print(f'{pkg} not installed — installing...')
        jmputils.jpip('install', pkg)
    else:
        print(f'{pkg} already installed.')



import pandas as pd
import numpy as np
print('pandas and numpy imported successfully!')

");
zetaVagabond1
Level III

Re: No Module named 'pandas'

yes, that did help me to ensure the folder gets added. thanks

jthi
Super User

Re: No Module named 'pandas'

Using that import is one of the checks we use in our JMP-Python applications to make sure everything has been setup.

I'm still holding out from using JMP19 due to many reasons, but it will make using JMP-Python integration easier. If I remember correctly in JMP19 it will be unnecessary, but I haven't verified it. JMP19 will also make it easier to check if packages have been installed as jmputils gets "is_installed" method. 

-Jarmo

Re: No Module named 'pandas'

In JMP 18, unpacking the site-packages.zip file and creation of the directory was done by the jsite.py script. JMP 19 does this internally in C++ code the first time Python is initiated.   The jsite.py script still exists as a backup for when the command line jpip.bat or jpip shell scripts are generated by Python Create JPIP CMD(). Or it's Python equivalent jmputils.create_jpip( dest_path ) .

JMP 19 improves scriptable package management by adding jmputils.is_installed( 'package_name' ), jmptuils.package_version( 'package_name' ) and pkg_dict = jmputils.packages().  These were late additions to 19.0, they are present, but not documented in the scripting index.  Later updates do have examples in the scripting index.

Recommended Articles