Am trying to use clr.AddReference and clr.AddReferenceToFile to import an assembly, but python(2.7) keeps making this error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
clr.AddReference("UnityEngine")
AttributeError: 'module' object has no attribute 'AddReference'
Can anyone tell me how to fix this.
3 Answers
Once I met this issue.
There is a package named clr while the pythonnet package's alias is also clr.
So I removed clr by "pip uninstall clr" and then installed pythonnet by 'pip install pythonnet'.
Finally, everything works well.
You must be using the wrong 'clr' module. remove it
pip uninstall clr
And then install pythonnet
pip install pythonnet
run the code
import clr
dir(clr)
if the reasult is as ['StyleBuilder', 'builtins', 'cached',....] then the problem is your IDE is installing the WRONG Clr module