Modules not loading after installing some python libraries through the python console

Hi everyone,

I installed a couple of Python libraries (ctk, cv2,…) and my slicer stopped working like before after I restarted it. The errors that I get when I launch the software are the following:

Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘getSlicerRCFileName’ is not defined
Traceback (most recent call last):
File “”, line 1, in
File “C:\D\S4R\python-install\Lib\imp.py”, line 170, in load_source
module = _exec(spec, sys.modules[name])
File “”, line 618, in _exec
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “C:/D/S4R/Slicer-build/lib/Slicer-4.13/qt-scripted-modules/AddManyMarkupsFiducialTest.py”, line 5, in

Operating system:Windows10
Slicer version:4.13.0

I would appreciate some help on this.
Thanks,
Atabak

We already use the ctk namespace for CTK (https://commontk.org/). Fortunately, ctk Python package does not seem to be a useful package, so you should just make sure that you or other packages don’t accidentally install it.

OpenCV is a huge collection of random stuff and there are many ways of making it out to be a Python package. It is entirely possible that some distributions can break Slicer.

If you find indispensable Python packages that seem to break Slicer then let us know and we can have a look.

Hi Andras,

Thank you for your response. Here are the packages that I intended to install: “cv2, scipy, sitkUtils, SimpleITK, vtk, qt, ctk” . Some of them were already installed but some weren’t.

So how do I uninstall ctk Python package that I just installed?

I’m trying to use

slicer.util. pip_uninstall` ( requirements )

But, I’m getting the following error:

Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘slicer’ is not defined

Thanks

These packages are already bundled with Slicer, do not try to reinstall them: scipy, sitkUtils, SimpleITK, vtk, qt, ctk (by the way, ctk is not a Python package from PyPI but a namespace where CTK library classes are imported into).

If you cannot uninstall it using pip_uninstall then you probably need to delete the entire application folder and reinstall Slicer, extensions, and Python packages from scratch.

OpenCV is a huge beast, it can break anything, depending on which variant you import. Which OpenCV packages have you tried to install?

What are you trying to achieve? Run Python scripts without showing the application GUI?