![](/img/trans.png)
[英]AttributeError: 'module' object has no attribute 'subscribe' Python
[英]Python: AttributeError: 'module' object has no attribute 'AddReference'?
我正在嘗試使用 clr.AddReference 和 clr.AddReferenceToFile 來導入程序集,但 python(2.7) 不斷出現此錯誤:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
clr.AddReference("UnityEngine")
AttributeError: 'module' object has no attribute 'AddReference'
誰能告訴我如何解決這個問題。
一旦我遇到這個問題。 有一個名為clr的包,而pythonnet包的別名也是clr 。 所以我刪除了由“CLR pip uninstall clr
”,然后安裝了pythonnet“ pip install pythonnet
”。 最后,一切正常。
您一定使用了錯誤的“clr”模塊。 去掉它
pip uninstall clr
然后安裝pythonnet
pip install pythonnet
運行代碼
import clr
dir(clr)
如果reasult是[“StyleBuilder”,“建宏”,“緩存”,...]那么問題就是你的IDE是安裝了錯誤的CLR模塊
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.