Python 2 to Python 3 .so library incompatibility - need help

MRAB python at mrabarnett.plus.com
Wed Dec 16 15:22:40 EST 2020


On 2020-12-16 19:16, Chris Angelico wrote:
> On Thu, Dec 17, 2020 at 6:06 AM Chris Green <cl at isbd.net> wrote:
>>
>> Some time ago (in July) I asked some questions here
>> about problems migrating some code from Python 2 to Python 3.
>>
>> The specific problem that finally prevented me from managing to get it
>> to work was a (Linux) .so file that had been built for Python 2 and,
>> as I don't have the source, I can't build for Python 3.
>>
>> I need to have another go at fixing this as otherwise the code that I
>> need to manage my printer will stop working as I update my Ubuntu
>> systems.
>>
>> The specific error I'm getting is as follows:-
>>
>>     File "/usr/libexec/okimfputl.new/guicom.py", line 66, in <module> import pyscand
>>     ImportError: /usr/libexec/okimfpdrv/pyscand.so: undefined symbol: _Py_ZeroStruct
>>
>> I know this is because the extension module is compiled for Python 2
>> and _Py_ZeroStruct is only available in Python 2.  I don't have the C
>> code for the module.
>>
>> Is there *any* other way around this, like a 'compatibility module' to
>> use Python 2 .so files in Python 3 or anything like it?  I have all
>> the Python code and have (up to hitting this problem) converted it to
>> Python 3.
>>
> 
> Basically no. The error you're seeing is a nice noisy one, but even if
> you got past that, there'll be a LOT of incompatibilities.
> Unfortunately, a quick google search for 'pyscand' showed up....
> places where you've asked this question, suggesting that nobody else
> uses this library. It looks like you're going to have to take a big
> step back and figure out what the library is doing for you, and
> reimplement that somehow. :(
> 
> Good luck.
> 
Alternatively, run something in Python 2.7 that can import it and talk 
to the main Python 3 code, at least until you have a long-term solution.


More information about the Python-list mailing list