Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: AttributeError: 'module' object has no attribute 'AddReference'?

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.

like image 329
Ran Avatar asked Dec 20 '17 19:12

Ran


People also ask

How do I fix Python module has no attribute?

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.

What is import CLR in Python?

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.


1 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.

like image 113
Guancheng Li Avatar answered Sep 21 '22 12:09

Guancheng Li