OverflowError: Python int too large to convert to C long


As the label names it, I am having issues w/ running some i2c-2 source on an am335x based, SiP board.

I deal w/ GPIO and I2C in my source for I/O.

This brief error was intended to not show but it arrived. I read an entire dialog about 34 on this forum from AUG 22, i.e. this year. Please forget the past and this message of 34 mentioning.

Okay, so.

Is there a way around using an address, i2c address, called 0xb6a81028 ?

I am sort of new to programming and learning very slowly.


The code that’s giving that error mesage is written in C or C++ and it’s using PyLong_AsLong, which returns a long, but the number 0xb6a81028 is too big for a long. It needs to be changed to use, say, PyLong_AsUnsignedLong and unsigned long.

1 Like


@MRAB , thank you for replying. I will try to find where the code is currently to change it to the specified value(s).


P.S. The reason I typed code is b/c I am using two libs. and a Linux FS. It could be located anywhere really.

From the trace back you can work out which module the code is on.
Then in the REPL you can import the module and type it’s name.
The Repr shows the path to the module in the fs.

>>> import json
>>> json
Repr showing path to json.py
1 Like