cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
rossjason
Level II

Python matplotlib import dll error when launched from JMP

I have a python script that imports pyplot from matplotlib. When I run this python script in any situation outside of JMP (from within Spyder IDE or just via windows command line), it runs just fine. But when I launch it using JMP's Run Program functionality, or even just with OPEN, it has an import error (see below).

 

I've narrowed the import error down top ft2font from matplotlib and I can replicate it from within JMP:

 

Names Default To Here( 1 );
RP = RunProgram(
Executable( "python.exe" ),
Options( {"-c \!"from matplotlib import ft2font\!""} ),
ReadFunction( Function( {this}, Write( this << read ) ) )
);

and here's the error:

 

RunProgram( /*object*/ )Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.

again, if I open a command prompt and run python.exe -c "from matplotlib import ft2font", I get no error. What's going on with JMP messing up python package imports? There is a very similar issue (see here) that some matplotlib users have in general with the imports in font_manager.py but those people cannot use it at all in any situation, for me it's only when calling from inside JMP.

 

 

4 REPLIES 4

Re: Python matplotlib import dll error when launched from JMP

What version of python are you using?

I get that error message when running the script with Python 2.7 but not with Python 3.6. I get the same behavior in both versions, in JMP and in command line.
If you have multiple python installations, you can use the below script to check the version JMP is using. If it is not using the expected version, you may need to provide the full path to the python executable.

ver = Trim( 
	Run Program(
		Executable( "python.exe" ),
		Options( "--version" ),
		Read Function( "text" )
	)
);

Show( ver );
Justin
rossjason
Level II

Re: Python matplotlib import dll error when launched from JMP

Both in JMP with the code you supplied and in command line, I am getting the same version:

 

ver = "Python 3.6.6 :: Anaconda custom (64-bit)";

Re: Python matplotlib import dll error when launched from JMP

Hmm. I'm not sure what it could be then. However, I am running a vanilla Python install and not an Anaconda distribution.

ver = "Python 3.6.4";
Justin
rossjason
Level II

Re: Python matplotlib import dll error when launched from JMP

OK, I solved this one and it's JMP's fault.

There's a zlib.dll living inside the JMP installation and since JMP adds itself to the PATH before launching windows commands, python was finding that zlib.dll before it found the zlib.dll that lives at C:\Anaconda3\Library\bin\zlib.dll even if you changed directory first via a batch file.

 

I had to make a batch file that first changes directory outside of JMP (where the cmd window starts), removes JMP from the path using the set command, then launches my python script as below

 

cd c:\
set PATH=%PATH:C:\Program Files\SAS\JMPPRO\14;=%
pythonw.exe "my_gui_app.py"

My python app now launches from a JMP button using the jsl Run Program command calling the batch file.