Statistica Python Node may fail to run in Live Score with Deprecation warning about imp module

Statistica Python Node may fail to run in Live Score with Deprecation warning about imp module

book

Article ID: KB0073562

calendar_today

Updated On:

Products Versions
Spotfire Statistica 13.6 and below

Description

Statistica workspace with Python Node failed to run in Live Score with below Deprecation warning about imp module:
--------------------------
C:\Windows\TEHP\tmpSBE2_py:32: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for an alternative uses
import imp
-------------------------- 
Python version 3.x was integrated with Statistica. 

User-added image
 

Issue/Introduction

Statistica Python Node may fail to run in Live Score with Deprecation warning about imp module

Environment

Windows

Resolution

This issue happens for Statistica version 13.6/13.5 and below, when Python 3.x is integrated with Statistica to execute the Python node. 

The warning "DeprecationWarning: the imp module is deprecated in favour of importlib" was due to depreciated module imp for higher versions of Python 3.x.

Statistica python node with this warning can still be executed successfully in Statistica application without any issue. 
This, however, has prevented the workspace from being successful when executed from Live Score. 

This issue has been fixed in Statistica version 14.0 and onwards.

For lower versions like Statistica version 13.5/13.6, to remove this Deprecation warning in Statistica and in Live Score, as a workaround, user can go to Statistica installation directory, typically at  C:/Program Files/Statistica/Statistica 13/, and find the file PyWrapper.py.

Open this file with text editor, it has below library import codes at the very beginning:
------------------
import sys
import imp
import tempfile
import time
import subprocess
-----------------

The Deprecation warning for import imp when running Python Node, comes from the code "import imp" above. 

User can first make a backup copy of it (PyWrapper.py), and then modify the code with below lines to suppress the warning from "import imp":
------------------
import sys

import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category = DeprecationWarning)
import imp

import tempfile
import time
import subprocess
----------------- 

Save the change in PyWrapper.py, and Re-run the workspace with Python Node.
The DeprecationWarning about imp module will disappear in Statistica, and in Live Score.