python - 'System.IO.FileNotFoundException : Unable to find assembly' in clr library on Python

标签 python windows .net-assembly

我在 .dll 文件中使用的代码中遇到汇编错误。这是template code from another thread ,很多人声称它有效。

import clr
import os
file = 'CPUThermometerLib.dll'
print('Does this filepath exist?',os.path.isfile(file)) 
clr.AddReference(file)

我猜文件路径没有问题,因为它在 .isfile 函数上返回 true。这是我得到的输出:

Does this filepath exist? True
  File "<stdin>", line 1, in <module>
System.IO.FileNotFoundException: Unable to find assembly 'CPUThermometerLib.dll'.
   at Python.Runtime.CLRModule.AddReference(String name)

我检查了多个线程,但没有一个给出解决方案。我使用的是 Windows 10,此外,我的 .NET Framework 版本是“4.0.30319.42000”。我的笔记本电脑处理器是 Atom Z3537F。

最佳答案

Windows python 安装中默认不安装 clr 模块。您需要在提示符下运行 pip install clr 来添加它,然后您的代码将能够正确导入它。

关于python - 'System.IO.FileNotFoundException : Unable to find assembly' in clr library on Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60714343/

相关文章:

python - 异步 : Is it possible to release control of the event loop without using yield from?

c++ - C++ 中的自定义文件扩展名

Java 无法识别的选项 : -xvf

.net - 安装后程序集依赖关系发生变化

python - 迭代类对象列表 - 'pythonic' 方式

python - 如何让 PyC​​harm 检查 PEP8 代码样式?

windows - 新创建的模态窗口失去焦点并在 Windows Vista 中变得不可访问

c# - ResolveEventHandler只调用一次,成功或失败

c# - 如何让 CLR 知道从 GAC 选择哪个程序集?

python - 如何从父实体获取后代