Spyder 3.6 AttributeError 中的奇怪行为:模块“EBL”没有属性“EBL”

问题描述

Atm 我正在努力解决一个问题,这让我发疯。这是我的问题:

问题:

我正在尝试使用 dll(称为 EBL.dll)连接硬件设备,以便发送和接收命令和测量结果。我的一位同事支持我,在他的工作站上使用相同的设置(操作系统、python 和 spyder 版本)一切正常。但是在我的情况下 spyder 总是丢弃错误消息

属性错误:模块“EBL”没有属性“EBL”

但是,当我按下播放按钮或在 spyder 中运行文件时,总是会发生这种情况。我检查了模块 EBL 的实例包含的属性,并将其与我的一位同事使用相同的设置、相同的包和相同的代码得到的属性进行了比较。这就是我得到的:

dir(EBL)
Out[18]: ['__doc__','__loader__','__name__','__package__','__path__','__spec__']

这就是我的同事得到的:

dir(EBL)
Out[3]:
['CheckDeviceNetConfig','ClearDeviceDiagnosticmemory','ConfigureCommandValueGenerator','ConfigureValveTestSignalgenerator','Connect','DeviceInfo','DeviceOscilloscope','disconnect','Eal','EasyStartUp','Enable','Equals','Finalize','GetHashCode','GetInterfaceInfo','GetType','InitializeforValveMessurement','IsEasyStartUpOn','IsEnableOn','IsParameterizationLevelOn','LoadParameterfile','LogFilePath','MemberwiseClone','Overloads','ParameterBitCheck','ParameterBitReset','ParameterBitSet','ParameterizationLevel','Password','PowerOff','PowerOn','ReadDataTo16BitArray','ReadListElement','ReadListUInt16','ReadListUInt32','ReferenceEquals','ResetPassword','SaveAllParametersToFile','SaveParametersToFile','SearchForDevices','SetDeviceNetworkConfig','SetDeviceOperatingHours','SetDeviceTime','SetDevicetoOpenLoop','SetMasterCommunicationSercos','SetPassword','SetValveController','SwitchDevicesToTCPIP','ToString','ValueGeneratorEnable','WaitForCommandStatus','WaitForParameterBits','WriteData','WriteListDouble','WriteListUInt16','WriteListUInt32','__call__','__class__','__delattr__','__delitem__','__dir__','__doc__','__eq__','__format__','__ge__','__getattribute__','__getitem__','__gt__','__hash__','__init__','__init_subclass__','__iter__','__le__','__lt__','__module__','__ne__','__new__','__overloads__','__reduce__','__reduce_ex__','__repr__','__setattr__','__setitem__','__sizeof__','__str__','__subclasshook__','get_DeviceInfo','get_DeviceOscilloscope','get_Eal','get_LogFilePath','get_Password','get_ValueGeneratorEnable','log','set_LogFilePath','set_Password','set_ValueGeneratorEnable']

正如您在我们都使用的以下最小示例中以某种方式看到的那样,我无法加载属性

我尝试了什么

我已经尝试了很多事情,例如:

  1. 使用最少的包(包括 pythonnet)创建新环境
  2. 通过不同方式安装pythonnet

conda install -n -c conda-forge pythonnet

pip install pythonnet

pip3 安装 pythonnet

顺便说一句。我知道 conda install 应该比 pip 更受欢迎;)

  1. 从我同事创建的 pickle 文件中加载模块作为带有 pickle 的实例
  2. 将他的工作环境复制并加载为 yml

最小工作示例

import clr
from os import sys
sys.path.insert(0,"C:/daten")
clr.AddReference('EBL')
import EBL as myebl 
import time
# from EBL import EBL

# Creates EAL connnection object
device = myebl.EBL()

顺便说一句:是的,所有文件都在同一个文件夹中,并且还设置了当前工作目录;)

这个问题与其他帖子中解决的问题有些不同,因为在这里我不尝试从 py 文件或类加载模块,而是从 dll。前一个工作得很好。

所以我需要回答的问题是:

1.为什么 python/spyder/anaconda 没有加载整个模块? 2. 如何让它加载整个模块?

提前谢谢你,很抱歉很长的文字;)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)