1

I am trying to import clr and receive the following error:

AttributeError: module 'clr' has no attribute 'AddReference'

I have tried to follow the steps here, where I uninstalled both pythonnet and clr, and then install pythonnet and then clr.

However, I still get the same error.

I'm using spyder 5.4.1 (on a virtual Windows machine).

Any help is greatly appreciated!

1
  • This happened to me. There was a CLR.py file that my env (PyCharm virtual env) was holding on to. Once I deleted that it was good to go Commented Oct 3, 2023 at 16:23

1 Answer 1

0

I was facing the same problem and came across your post (and also your link). The solution for me in spyder was to DIABLE the "User Module Option" (UMR) option under:

Preferences --> Python Interpreter --> UMR

It seems that spyder thinks it has to reload the wrong (and previously uninstalled) clr package when using the "rufile" command (which you do by hitting F5 to launch your script). I hope it helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.