我在这里看到了很多有同样问题的问题,但我还没有找到一个有效的解决方案。我正在试着运行这个face tracking program,但是我不能让它工作。我知道程序说它是为python2.7编写的,但据我所知,语言结构没有太大区别,对吧?我对python的基本知识有很好的理解,但我还在继续学习。
这个问题在标题中,我通过mac上的终端下载了pyserial、open-cv和numpy到/3.8/bin中。然而,当我尝试运行下面的代码时,它抛出了一个AttributeError,就像我没有安装串行一样。我是不是漏掉了什么,或者读错了什么?任何帮助都将不胜感激。
输入:
#import all the required modules
import numpy as np
import serial
import time
import sys
import cv2
arduino = serial.Serial('/dev/cu.usbmodem14201', 9600) 错误:
Traceback (most recent call last):
File "/Users/daPWNDAZ/Desktop/Arduino/Codes/FaceTracking/face.py", line 7, in <module>
arduino = serial.Serial('/dev/cu.usbmodem14201', 9600)
AttributeError: module 'serial' has no attribute 'Serial'发布于 2020-06-30 06:20:01
显然,您的目录中有一个名为"serial“的python脚本。重命名该文件,您就会感觉很好
发布于 2020-07-01 23:15:45
我找到答案了!我找不到任何名为"serial“的文件,所以我在gre_gor给出的答案中做了更多的挖掘。通过从命令行卸载pyserial并重新安装它(如第二个链接中所建议的),它得到了修复,我发誓我已经这样做了。我不会再收到任何错误了,谢谢大家!
https://stackoverflow.com/questions/62647147
复制相似问题