On my Mac, I am running both Python 2.7 and 3.2. I recently needed to access a serial port (via a USB-to-serial converter), so I did some research and settled on pyserial as the software interface. At the time of this writing, pyserial v2.5 is the most current version.

After downloading and extracting the tar file, running the installer is the only thing left to do:

tar xfvz pyserial-2.5.tar.gz
cd pyserial-2.5
sudo python setup.py install

All went well. Then I tried to install for Python 3:

sudo python3 setup.py install

which gave me:

running install
running build
running build_py
running build_scripts
running install_lib
byte-compiling /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/serial/loopback_connection.py to loopback_connection.pyc
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/serial/loopback_connection.py", line 101
    except ValueError, e:
                     ^
SyntaxError: invalid syntax

followed by a large number of similar syntax errors.

A bit of searching revealed a bug ticket describing exactly this issue.

The solution is simple:

sudo rm -Rf build
sudo python3 setup.py install

When the next version of pyserial is released, this problem will be resolved. 🙂

 

I appears that this is a problem specific to Mac OS X, by the way. When I tried the same thing on Linux (Ubuntu 11.04, don’t get me started …) both installs were fine. I don’t know about Windows, post a comment if you do.