OverflowError: Python int too large to convert to C long

I was able to setup my raspberry pi using Method 1 mentioned here.

Below is my simple code. Just trying to create instance of rvr using SpheroRvrObserver()

import os
import sys
import time
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../')))

from sphero_sdk import Colors
from sphero_sdk import SpheroRvrObserver

rvr = SpheroRvrObserver()

After running program I am getting below error

(sphero-sdk-raspberrypi-python) pi@raspberrypi:~/sphero-sdk-raspberrypi-python/getting_started/observer/leds $ (sphero-son a.pyberrypi-python) pi@raspberrypi:~/sphero-sdk-raspberrypi-python/getting_started/observer/leds $ sudo pyth
Traceback (most recent call last):
  File "a.py", line 6, in <module>
    from sphero_sdk import Colors
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/__init__.py", line 20, in <module>
    from sphero_sdk.common.enums.sensor_enums import MotorIndexesEnum as SensorMotorIndexesEnum
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/common/enums/sensor_enums.py", line 83, in <module>
    class InfraredSensorLocationsBitmask(IntEnum):
  File "/usr/lib/python2.7/dist-packages/enum/__init__.py", line 230, in __new__
    enum_member = __new__(enum_class, *args)
OverflowError: Python int too large to convert to C long
(sphero-sdk-raspberrypi-python) pi@raspberrypi:~/sphero-sdk-raspberrypi-python/getting_started/observer/leds $

python version is 3.7.3

Am I missing anything?

1 Like

Hi @hshelar,

You shouldn’t need to use sudo to run python scripts. Maybe that’s causing an issue?


1 Like

Hi Guys,

I am getting the same error. I have tried to run it through the SSH and then directly on the Pi with a monitor. I can get the Keyboard program to work and move the RVR. However, all the other Python programs return the:

Python int too large to convert to C long

Any other ideas for finding a solution appreciated! Thanks!!

Hi @hshelar and @Rafiki77,

I just noticed this line in @hshelar’s output, which shows the error is from a Python2.7 package.

Can you both reply with some more console history as context for how you’re running the scripts? It really seems like they’re running in Python2.7 and not Python 3.5+ as required.


SPHERO Email Marketing -