我刚刚安装了Pyserial 2.6,我有Python 2.7.3,不幸的是它没有正确安装,或者我没有正确使用它。我安装了它通过终端使用线路运行Pyserial时出错
sudo easy_install pyserial
不幸的是它给了我2个警告:
比它似乎正确安装warning: no files found matching 'examples/miniterm.py'
warning: no files found matching 'test/test_io_lib.py'
其他。
当我运行这个在Python我不断收到以下错误更远
import serial
serial_input = serial.Serial('/dev/tty/.usbmodem3d241',9600)
while True:
ser.readline()
错误:
Traceback (most recent call last):
File "/Users/ben/Documents/Arduino_to_Python.py", line 5, in <module>
serial_input = serial.Serial('/dev/tty/.usbmodem3d241',9600)
File "build/bdist.macosx-10.7-intel/egg/serial/serialutil.py", line 261, in __init__
self.open()
File "build/bdist.macosx-10.7-intel/egg/serial/serialposix.py", line 278, in open
raise SerialException("could not open port %s: %s" % (self._port, msg))
SerialException: could not open port /dev/tty/.usbmodem3d241: [Errno 20] Not a directory: '/dev/tty/.usbmodem3d241'
无论串口我尝试它似乎永远不会工作。我曾尝试在Arduino程序工具>串行端口和所有的提示http://pyserial.sourceforge.net/shortintro.html#opening-serial-ports
任何帮助将不胜感激。谢谢。
你确定路径确实存在?看一下shell中的'/ dev/tty'。 –
是不是'dmesg | grep usbmodem'给出了设备路径的线索。 –
我试图从pyserial网站到没有avial。对于路径应该是什么? >>> SER = serial.Serial() >>> ser.baudrate = 19200 >>> ser.port = 0 >>> ser.open() 回溯(最近通话最后一个): 文件““,第1行,在 ser.open() 打开文件”build/bdist.macosx-10.7-intel/egg/serial/serialposix.py“,第278行 raise SerialException(”could not open port %s:%s“%(self._port,msg)) SerialException:无法打开端口0:[Errno 2]没有这样的文件或目录:'/ dev/cuad0' –
ben