【问题标题】:Attribute error when using pyserial in psychopy在psychopy中使用pyserial时出现属性错误
【发布时间】:2021-08-07 08:19:36
【问题描述】:

我正在使用psychopy 并使用pyserial 模块。我最近从使用笔记本电脑转移到了台式机。在桌面上,当我在空闲时使用测试脚本时,我已经成功地实现了以下内容:

ser = serial.Serial()

但是,当我使用psychopy coder 运行一些代码时,我不断收到一个属性错误,提示模块序列号没有属性序列号。此代码之前已在我的笔记本电脑上成功运行。

Hello from the pygame community. https://www.pygame.org/contribute.html
0.8191     WARNING     We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).
Traceback (most recent call last):
  File "C:\Users\uqakriti_local\Desktop\MSI Face Motor Project\MSI Face Motor Project\MSIthreadcodeinstructions.py", line 35, in <module>
    ser = serial.Serial()
AttributeError: module 'serial' has no attribute 'Serial'

我已尝试卸载并重新安装串行模块,但仍然看到相同的属性错误。有没有人对此有任何可能的解决方案?

【问题讨论】:

  • 你能告诉我们你在哪里导入serial模块的代码
  • 抱歉格式化 - stackoverflow 的新手import _thread import serial import time import sys ser = serial.Serial()

标签: python module pyserial attributeerror psychopy


【解决方案1】:

您可以尝试使用以下命令导入模块

from serial import Serial

也可以通过这个帖子credits

【讨论】:

    猜你喜欢
    • 2016-06-14
    • 1970-01-01
    • 2021-07-01
    • 2021-07-18
    • 2021-01-16
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多