"RuntimeError: invalid slot offset" on trying to run python package

Viewed 241

I use the pyhyphen package for a script I run all the time. Recently, I updated to MacOS Big Sur. Spyder was laggy, but I fixed that by running a virtual environment and pip installing what I needed. No issues.

Now, when I try to run from hyphen import Hyphenator (here is the package page), I get the following error:

[autoreload of hyphen.dictools failed: Traceback (most recent call last):
  File "/Users/myname/anaconda3/lib/python3.8/site-packages/IPython/extensions/autoreload.py", line 245, in check
    superreload(m, reload, self.old_objects)
  File "/Users/myname/anaconda3/lib/python3.8/site-packages/IPython/extensions/autoreload.py", line 394, in superreload
    module = reload(module)
  File "/Users/myname/anaconda3/lib/python3.8/imp.py", line 314, in reload
    return importlib.reload(module)
  File "/Users/myname/anaconda3/lib/python3.8/importlib/__init__.py", line 159, in reload
    raise ImportError(msg.format(parent_name),
ImportError: parent 'hyphen' not in sys.modules
]


runcell(0, '/Users/myname/Documents/project/project.py')
Traceback (most recent call last):

  File "/Users/myname/Documents/project/project.py", line 17, in <module>
    from hyphen import Hyphenator

  File "/Users/myname/anaconda3/lib/python3.8/site-packages/hyphen/__init__.py", line 10, in <module>
    from .hyphenator import Hyphenator

  File "/Users/myname/anaconda3/lib/python3.8/site-packages/hyphen/hyphenator.py", line 27, in <module>
    from . import hnj

RuntimeError: invalid slot offset

The from hyphen import Hyphenator is the only line in the script. I've tried uninstalling/reinstalling the package six hundred times - and I cannot find any kind of solution for invalid slot offset. All other packages import fine, no issues.

Spyder (in Anaconda) is running python version 3.8.5. I have non-anaconda 3.9 installed, but I can't imagine that has any effect since I'm running spyder in a virtual environment.

2 Answers

it seems the problem when installing the package .in this line of code from setup.py

ext_modules=[
        Extension('hyphen.hnj', ['lib/hnjmodule.c',
                                 'lib/hyphen.c',
                                 'lib/hnjalloc.c'],
                  include_dirs=['lib'],
                  py_limited_api=True)
                  ],

the package hnj is not compiled correctely

try to installe nd build the package manually

I suggest you to install via anaconda, not pip:

source /Users/myname/anaconda3/bin/activate
conda install -c auto pyhyphen
Related