I've seen a lot of questions on here that have this same issue, but I haven't found a solution that works yet. I'm trying to run this face tracking program, but I can't get it to work. I know that the program says that it's written for python 2.7, but as far as I know there isn't that much of a difference in the language structure, right? I have a pretty firm understanding of the basics of python, but I'm still going through school.
The issue is in the title, I downloaded pyserial, open-cv and numpy through the terminal on mac into /3.8/bin. However, when I try to run the code below, it throws an AttributeError like I don't have serial installed. Am I missing something, or misreading something? Any help would be greatly appreciated.
Input:
#import all the required modules
import numpy as np
import serial
import time
import sys
import cv2
arduino = serial.Serial('/dev/cu.usbmodem14201', 9600)
Error:
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'
2 Answers 2
Apparently you have a python script in your directory named "serial". Rename that file and you should be good
1 Comment
I found an answer! I couldn't find any files named "serial", so I dug around a bit more in the answers gre_gor gave. It got fixed by uninstalling pyserial from the command line and reinstalling it (as suggested in the second link), which I could have sworn I had already done. I'm not getting any errors anymore, thank you all!
ImportError. This looks more like you have aserial.pyfile somewhere, that is being imported instead of the actual module. Doimport serial; print(serial.__file__)to see where it is.