Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing serial ports in Mac OS X and Python 3

I'm having trouble listing available serial ports and I really need help debugging this. In Python 2.7.5 the COM-ports are listed correctly while PySerial returns an empty list in Python 3.3.5.

I found one other lonely soul with the same problems on the internet (no answers), but the problem doesn't seem to be popular at all - maybe it's my system?

I'm using Mac OS X 10.9.2 and installed python and python3 via homebrew. I updated everything just now. PySerial is at version 2.7 in both pip and pip3.

The output:

Python 2.7.5 (default, Nov  4 2013, 18:04:45) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[['/dev/cu.Bluetooth-Incoming-Port', 'n/a', 'n/a'], ['/dev/cu.Bluetooth-Modem', 'n/a', 'n/a']]

Python 3.3.5 (default, Mar 10 2014, 13:25:50) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[]
like image 273
tfeldmann Avatar asked Mar 17 '14 23:03

tfeldmann


People also ask

How do I find python3 path on Mac?

The Apple-provided build of Python is installed in /System/Library/Frameworks/Python. framework and /usr/bin/python , respectively.

Does macOS have Python 3?

Apple says that developers should use an alternative scripting language going forward, such as Python 3, but it's worth noting that Python 3 also does not come preinstalled on macOS. Developers can run the stub /usr/bin/python3 in Terminal, but it prompts users to install Xcode developer tools, which includes Python 3.


1 Answers

For the moment I'm resorting to the following method. The PySerial tools are broken.

>>> import glob
>>> glob.glob('/dev/tty.*')
['/dev/tty.Bluetooth-Incoming-Port', '/dev/tty.Bluetooth-Modem']
like image 70
tfeldmann Avatar answered Sep 20 '22 09:09

tfeldmann