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.
To solve the Python "AttributeError: module has no attribute", make sure you haven't named your local modules with names of remote modules, e.g. datetime.py or requests.py and remove any circular dependencies in import statements.
Project descriptionNET Common Language Runtime (CLR) and provides a powerful application scripting tool for . NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a . NET application.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With