Jump to content

Error loading matplotlib python module in Spotfire Analyst


Luke George

Recommended Posts

I am trying to deploy python modules as an .spk file to Spotfire sever and then import those modules in Spotfire analyst (10.8) in Data Function Properties. Everyhting works fine when I create a.spk file without the matplotlib module (or any module that depends on matplotlib). When I add matplotlib to my requirements.txt file, the .spk creation works, and the server deployment works,but then when I try to load any module in Spotfire analyst (not just the matplotlib module specifically), I get the following error:

Could not execute function call 'Untitled'

Traceback (most recent call last):

File "(init script)", line 4, in

import spotfire.data_function as dfn

File "", line 983, in _find_and_load

File "", line 967, in _find_and_load_unlocked

File "", line 668, in _load_unlocked

File "", line 638, in _load_backward_compatible

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesCore_44.0.14430.3578pythonspotfire.zipspotfiredata_function.py", line 11, in

File "", line 983, in _find_and_load

File "", line 967, in _find_and_load_unlocked

File "", line 668, in _load_unlocked

File "", line 638, in _load_backward_compatible

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesCore_44.0.14430.3578pythonspotfire.zipspotfiresbdf.py", line 29, in

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 1015, in

rcParams = rc_params()

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 878, in rc_params

return rc_params_from_file(matplotlib_fname(), fail_on_error)

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 731, in matplotlib_fname

for fname in gen_candidates():

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 728, in gen_candidates

yield os.path.join(get_configdir(), 'matplotlibrc')

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 276, in wrapper

ret = func(**kwargs)

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 609, in get_configdir

return _get_config_or_cache_dir(_get_xdg_config_dir())

File "C:Usersluke.georgeAppDataLocalTIBCOSpotfire10.8.0ModulesPython Packages_1.0.0.0site-packagesmatplotlib__init__.py", line 562, in _get_xdg_config_dir

return os.environ.get('XDG_CONFIG_HOME') or str(Path.home() / ".config")

AttributeError: type object 'Path' has no attribute 'home'

 

at Spotfire.Dxp.Data.DataFunctions.Executors.LocalPythonFunctionClient.d__8.MoveNext()

at Spotfire.Dxp.Data.DataFunctions.Executors.PythonScriptExecutor.d__11.MoveNext()

at Spotfire.Dxp.Data.DataFunctions.DataFunctionExecutorService.d__8.MoveNext()

 

Any idea why this is

Link to comment
Share on other sites

I am updating Spotfire analyst when I deploy a new .spk. I've tried now with the previous version of matplotlib but it still didn't work. My requirements.txt looks like this:#### requirements.txt ####matplotlib != 3.2.1

plotly == 4.5.0

seaborn == 0.10.0

scipy == 1.4.1

sklearn == 0.0

pyrolite == 0.2.4

opencv-python == 4.2.0.32

Pillow == 7.0.0

Image == 1.5.28

boto3 == 1.11.17

statsmodels  == 0.10.1

scikit-image  == 0.16.2

PyWavelets == 1.0.3

Link to comment
Share on other sites

First of all, I am not sure why you used != in your requirements.txt file for Matplotlib.

 

I created my requirements.txt as 

 

#### requirements.txt ####

matplotlib == 3.2.1

 

 

 

I created a .spk file and deployed it on the server. Later I updated my Analyst client and created a simple python data function with the code:

 

import matplotlib
x=matplotlib.__version__

 

 

 

I collected the 'x' in a document property and I am able to get the version as 3.2.1 in it.

 

annotation_2020-03-23_125904.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...