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.
7 comments
Comments feed for this article
February 24, 2014 at 19:37
Roger
Many thanks.
I had searched many days but this is the solution.
You are the hero, my batman.
Roger
February 24, 2014 at 22:10
Christian
I’m glad I could help. 🙂
September 8, 2014 at 13:55
Sam
Thank you 🙂 Super handy
September 8, 2014 at 16:05
Christian
You’re welcome, I’m glad I could help. 🙂
September 18, 2014 at 14:32
Ivan
Thank you, I needed this to get my IMU up and running
November 23, 2018 at 13:01
ronzensci
This has been a life saver.. Thank you so much!
November 23, 2018 at 14:03
Christian
I’m glad it helped you!