Integrating JMP with Anaconda Python and TensorflowI'm working to integrate an Anaconda environment of Python 3.8.11 with JMP to leverage Tensorflow with JMP.
I've been successful integrating JMP and the Anaconda environment and was able to verify operation of some typical machine learning packages installed in that environment. I have been unsuccessful in importing Tensorflow. Please see the attached code.
Names Default To Here( 1 );
Python Init(
Path( "C:\ProgramData\Anaconda3\envs\JMP ML\python38.dll" ),
Python Sys Path(
{"",
"C:\\ProgramData\\Anaconda3\\envs\\JMP ML\\DLLs",
"C:\\ProgramData\\Anaconda3\\envs\\JMP ML\\lib",
"C:\\ProgramData\\Anaconda3\\envs\\JMP ML\\libs",
"C:\\ProgramData\\Anaconda3\\envs\\JMP ML",
"C:\\ProgramData\\Anaconda3\\envs\\JMP ML\\lib\\site-packages"
}
)
);
Show( Python Get Version() );
Python Submit( "\[
import pandas as pd
print("Pandas Version: ", pd.__version__)
import numpy as np
print("NumPy Version: ", np.__version__)
import scipy
print("SciPy Version: ", scipy.__version__)
]\");
Python Submit( "\[
import tensorflow as tf
print(tf.__version__)
]\");
Python Term();The above produces the following output in my embedded log:
Python Get Version() = {3, 8, 11, "final", 0};
Pandas Version: 1.3.2
NumPy Version: 1.20.3
SciPy Version: 1.6.2
/**********/
import tensorflow as tf
print(tf.__version__)
/**********/
0When I add the statement: import tensorflow as tf
...to the first instance of Python Submit, it produces results similar to the second instance of Python Submit in that it appears that the python code is just printed into the embedded log. I've verified that indeed I do have tensorflow installed in the environment I'm referencing. I have also tested other packages installed in that environment and some produce the correct results while others produce what I'm calling the printed (non-functional) output.
Any ideas as to why tensorflow is not being imported correctly? I have a ticket in with support but was curious if the community might be able to help.
Thank you in advance for any suggestions/insights.
Data AccessWindowsRe: Integrating JMP with Anaconda Python and TensorflowSo indeed my theory was correct and the issue stemmed from a bad h5py package.
Steps to integrate an Anaconda hosted python environment with Tensorflow:
- Create a new python Environment in Anaconda. I named mine "JMP ML" for the script example below. (I've reproduced this with python 3.8.11 on 9/2/2021 multiple times)
- Install matplotlib, pandas, numpy, and scipy.
- Check the installed version of h5py. Anaconda will probably tell you it's 2.10.0. If this is the case, open a terminal window and use pip install h5py==3.1.0
- Install Tensorflow (for my repro I used v2.3).
- Open JMP and execute a script similar to the one linked in this post. The key parts are adding in the correct path and python system path for your environment. What I've learned is that JMP will default to your base (root) version of python from anaconda assuming you have no other python versions installed outside anaconda.
Names Default To Here( 1 );
Python Init(
Path( "D:\Anaconda\envs\JMP ML\python38.dll" ),
Python Sys Path(
{"",
"D:\\Anaconda\\envs\\JMP ML\\DLLs",
"D:\\Anaconda\\envs\\JMP ML\\lib",
"D:\\Anaconda\\envs\\JMP ML\\libs",
"D:\\Anaconda\\envs\\JMP ML",
"D:\\Anaconda\\envs\\JMP ML\\lib\\site-packages"
}
)
);
Show( Python Get Version() );
Python Submit( "\[
<BR />import matplotlib as mpl<BR />print("MatPlotLib: ", mpl.__version__)<BR />
import pandas as pd
print("Pandas Version: ", pd.__version__)
import numpy as np
print("NumPy Version: ", np.__version__)
import scipy
print("SciPy Version: ", scipy.__version__)
import tensorflow as tf
print("Tensorflow Version: ", tf.__version__)
]\");
Python Term();This code provides me with:
Python Get Version() = {3, 8, 11, "final", 0};
MatPlotLib: 3.4.2
Pandas Version: 1.3.2
NumPy Version: 1.20.3
SciPy Version: 1.6.2
Tensorflow Version: 2.3.0
0And these match the versions I have installed in Anaconda in the python 3.8.11 environment.
Re: Integrating JMP with Anaconda Python and TensorflowAs an additional clue, I've found that if I add in the following:
help("modules")<BR />help("tensorflow").. into my Python Submit block, tensorflow is listed as an installed module and for the second help I get back:
problem in tensorflow - AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__'
This to me suggests that h5py might be an issue.
If this sparks any interest or ideas, I'm still happy to hear them.
Re: Integrating JMP with Anaconda Python and TensorflowIn fact no question is silly and yes I did install Tensorflow.
Re: Integrating JMP with Anaconda Python and TensorflowSorry if this is a silly question, but did you install tensorflow? I ask because the other three libraries you showed come with the anaconda installer. Where tensorflow does not.
https://docs.anaconda.com/anaconda/packages/py3.8_win-64/
Re: Integrating JMP with Anaconda Python and TensorflowI'm not using Anaconda or virtual environments. I just installed with
pip3 install --user --upgrade tensorflow
and got this output with your example
Python Init();
0
Show( Python Get Version() );
Python Get Version() = {3, 9, 5, "final", 0};
Python Submit( "\[
import pandas as pd
print("Pandas Version: ", pd.__version__)
import numpy as np
print("NumPy Version: ", np.__version__)
import scipy
print("SciPy Version: ", scipy.__version__)
]\");
Pandas Version: 1.2.4
NumPy Version: 1.20.3
SciPy Version: 1.6.3
0
Python Submit( "\[
import tensorflow as tf
print(tf.__version__)
]\");
2.6.0
0
Python Term();
0There were a lot of messages in the install about paths. Let us know if you get a more helpful answer.
View more...