python - PySimpleDMX 不知道自己的类
问题描述
我一直试图让这个模块工作,但由于某种原因,它看起来不知道自己的类
这是我的代码:
import pysimpledmx
mydmx = pysimpledmx.DMXConnection(3)
这是我需要从 PySimpleDMX 获取的代码:
class DMXConnection(object):
def __init__(self, comport = None):
'''
On Windows, the only argument is the port number. On *nix, it's the path to the serial device.
For example:
DMXConnection(4) # Windows
DMXConnection('/dev/tty2') # Linux
DMXConnection("/dev/ttyUSB0") # Linux
'''
self.dmx_frame = [0] * DMX_SIZE
try:
self.com = serial.Serial(comport, baudrate = COM_BAUD, timeout = COM_TIMEOUT)
except:
com_name = 'COM%s' % (comport + 1) if type(comport) == int else comport
print "Could not open device %s. Quitting application." % com_name
sys.exit(0)
print "Opened %s." % (self.com.portstr)
我想使用 DMXConnection 时遇到的错误:
AttributeError: module 'pysimpledmx' has no attribute 'DMXConnection'
但是如你所见,DMXConnection 是 pysimpledmx 的一个属性。我尝试使用 PIP 重新安装模块,但没有成功。
解决方案
这是一个废弃的Python 2包,要么安装它并将其与 Python 2 版本一起使用,要么将模块文件复制到项目中并尝试调试它。
推荐阅读
- javascript - 如何将字符串 (°C) 添加到表中的数据?
- java - Jsoup提取div的孩子
- c# - 强制 BindableProperty propertyChanged 即使在 Xamarin 表单中使用相同的值也会触发
- javascript - 如何显示来自 api 的 ajax 响应的错误消息?
- php - 在 woocommerce 单品页面中将打印的通知移到页面标题上方
- javascript - 如何在 config.js 中定义多个常量
- kubernetes - 同步期间出错:UpdateURLMap:googleapi:错误 413:字段 resource.pathMatchers[0].pathRules 的值太大
- javascript - 选择一个对象并打印它的属性AngularJS
- logging - 如何对日志事件做出反应 err、crit、alert、emerg?
- c++ - Arduino Capturing lambda 函数作为参数