nameError when using slicer.util.pip_install

Hi, I’m working on the TCIABrowser extension. Part of the code relies on a PyPI package called tcia_utils. The code we used to load it worked fine in the 5.2 stable release, but in the 5.3 preview releases this is failing. Did something change about how we should be doing things or is this a bug related to slicer.util?

slicer.util.pip_install(‘tcia_utils’)
NameError: name ‘slicer’ is not defined

Here’s the full traceback:

Traceback (most recent call last):
File “C:\Users\neoma\Downloads\TCIABrowser-master\TCIABrowser\TCIABrowserLib\TCIAClient.py”, line 2, in
import tcia_utils.nbia
ModuleNotFoundError: No module named ‘tcia_utils’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\neoma\AppData\Local\slicer.org\Slicer 5.3.0-2023-06-19\lib\Python\Lib\imp.py”, line 169, in load_source
module = _exec(spec, sys.modules[name])
File “”, line 613, in _exec
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “C:/Users/neoma/Downloads/TCIABrowser-master/TCIABrowser/TCIABrowser.py”, line 23, in
from TCIABrowserLib import APISettingsPopup, clinicalDataPopup, TCIAClient
File “C:\Users\neoma\Downloads\TCIABrowser-master\TCIABrowser\TCIABrowserLib\TCIAClient.py”, line 4, in
slicer.util.pip_install(‘tcia_utils’)
NameError: name ‘slicer’ is not defined

slicer.util.pip_install(‘tcia_utils’)
NameError: name ‘slicer’ is not defined

Calling import slicer before slicer.util.... should fix the problem.

Yikes…how did I miss that? :laughing: Thanks.