我pythonnet
在MSMQ通信中使用该程序包。在我的IDE(PyCharm CE)中,我有以下示例代码:
#!/usr/bin/env python3
import pythoncom
import clr
clr.AddReference("System")
clr.AddReference("System.Messaging")
from System import TimeSpan
from System.Messaging import MessageQueue
顺便说一句:当我实际使用Python运行该代码时,该代码运行良好3.6
。
下面是PyCharm内部外观的屏幕截图。
System
它说:Unresolved reference 'System'
除了使用noqa
注释,我如何才能让PyCharm linting执行以下操作:
from System import XYZ
吗?版本信息
2019.2
2.3.0
,安装在虚拟环境中根据我们的交往,这是我的完整答案。
没有名为clr的模块
经过一些检查,似乎操作系统环境与项目的虚拟环境之间存在某种混合。
解决方案:删除并重新创建正确修复的虚拟环境
未解决的参考“系统”
在这种情况下,相应的模块是动态加载的,最好的解决方案是在这些特定的行上禁用PyCharm的Inspector。因此,您不会在IDE中失去其他任何东西。
您可以看到如何禁用检查。
在我的沙箱中,我只需要:
More actions
错误上的上下文菜单(System
在这种情况下)Ignore unresolved reference 'pythonnet_tests.System'
子菜单Suppress for statement
每次对应的源代码行,都会在注释行之前:
# noinspection PyUnresolvedReferences
就是这样!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句