No module named 'clr' error

Hello,
I use a module and I get the following error when they try to import clr:
“No module named ‘clr’ error”
I tried to import pythonnet by using: pip_install(‘pythonnet’).
But when I restart 3DSlicer I get the following pop up and
image

Any idea that can be helful?
Thank you

Does installing pythonnet in a system python (not Python integrated into Slicer) such as Python 3.9.10 work for you? Do you have the same import error?

Slicer uses an integrated Python 3.9.10, but pypi says there is not an available whl for this python package for Python 3.9 (pythonnet · PyPI) so it’s likely trying to build from source which can open you up to many errors if you don’t have all the required build tools.

See the answer to this question in the pythonnet issue tracker:

Thanks for the answer.
I installed the --pre pythonnet in Slicer 4.13, but seems that I get the same error:
image

Also, I checked the PYTHONPATH and I get the following:
image

Thanks for your help,
Eleni

I’ve tested pythonnet with latest Slicer Preview Release on Windows, installed using

pip_install('--pre pythonnet')

Everything seems to work well. Your problem most likely is not related to pythonnet.

A software component overwriting PYTHONPATH would be completely unacceptable, and announcing this in a popup called “Delete Files” makes things even more bizarre. I would recommend to contact the developers of the code that displays this message to sort this out. If they cannot make their software compatible without such a huge hack then I would recommend not to try to integrate it directly with Slicer, but instead send data to Slicer via OpenIGTLink, using pyigtl.

Yes, you are right, the problem is coming from that package that I was using.
I could reproduce it on their side as well. Thanks for your help

1 Like