inbinder
inbinder

Reputation: 722

Pyserial version 2.6 not working after install on python3

This is the error that I get after typing import serial. I'm running osx snow leopard, python3.2 and there were no errors when I installed pyserial.

       import serial
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "serial/__init__.py", line 21, in <module>
    from serial.serialposix import *
    File "serial/serialposix.py", line 64
    50:      0000001,
               ^

Upvotes: 1

Views: 1663

Answers (2)

Martijn Pieters
Martijn Pieters

Reputation: 1121486

Make sure to install pyserial with the included setup.py script, or better still, use pip or distribute to install the package for you.

The pyserial code base is written for python 2 but the 2to3 code translator will be run on the code base when installing with python 3.

Upvotes: 2

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 262919

0000001 is an invalid token in Python 3, because it used to be parsed as an octal literal in Python 2, and that behavior was dropped in favor of the 0o prefix.

0o0000001 would work (as would 0o1, or simply 1).

I don't exactly know why your version of pySerial contains such a literal, but it will not work on Python 3 as it is. Try upgrading, as Martijn suggests.

Upvotes: 3

Related Questions