尝试导入使用swig的python库时出现“错误的ELF类”错误

时间:2019-09-20 14:44:53

标签: python swig importerror elf

我一直在尝试导入一个使用swig的名为dwave tabu的python库,但是我遇到了一些问题。在python3中导入包时,得到以下结果:

    >>>import tabu
    Traceback (most recent call last):
    File "/home/chip/.local/lib/python3.5/site-  packages/tabu/tabu_search.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
    File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 986, in _gcd_import
    File "<frozen importlib._bootstrap>", line 969, in   _find_and_load
    File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
    File "<frozen importlib._bootstrap>", line 577, in module_from_spec
    File "<frozen importlib._bootstrap_external>", line 914, in create_module
   File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
   ImportError: /home/chip/.local/lib/python3.5/site-packages/tabu/_tabu_search.so: wrong ELF class: ELFCLASS64
   During handling of the above exception, another exception occurred:
   Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/chip/.local/lib/python3.5/site-packages/tabu/__init__.py", line 17, in <module>
   from tabu.tabu_search import TabuSearch
   File "/home/chip/.local/lib/python3.5/site-  packages/tabu/tabu_search.py", line 17, in <module>
   _tabu_search = swig_import_helper()
   File "/home/chip/.local/lib/python3.5/site-packages/tabu/tabu_search.py", line 16, in swig_import_helper
   return importlib.import_module('_tabu_search')
   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in   import_module
   return _bootstrap._gcd_import(name[level:], package, level)
   ImportError: No module named '_tabu_search' 

我怀疑该错误与swig有关,但我不确定该如何解决。另外,似乎是一个错误,可能是由于在32位安装上为64位linux编译的二进制文件引起的,但我不知道如何解决该问题。任何帮助将不胜感激。 谢谢

1 个答案:

答案 0 :(得分:0)

  

ImportError: /home/chip/.local/lib/python3.5/site-packages/tabu/_tabu_search.so: wrong ELF class: ELFCLASS64

此错误的意思是:您试图将64位_tabu_search.so库加载到32位进程中。您必须使用64位的python或安装32位版本的tabu_search软件包。

  

我怀疑该错误与swig有关

不,SWIG与您的问题无关。