ctypeslib icon indicating copy to clipboard operation
ctypeslib copied to clipboard

ctypeslib2 gives following error on any anaconda environment whenever installed with pip.

Open murat-bal opened this issue 2 years ago • 3 comments

In any conda environment

$ pip install ctypeslib2 clang

$ clang2py Traceback (most recent call last): File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/site-packages/clang/cindex.py", line 4173, in get_cindex_library library = cdll.LoadLibrary(self.get_filename()) File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/ctypes/init.py", line 460, in LoadLibrary return self._dlltype(name) File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/ctypes/init.py", line 382, in init self._handle = _dlopen(self._name, mode) OSError: /home/muratbal/anaconda3/envs/gst_env/lib/clang: cannot read file data: Is a directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/muratbal/anaconda3/envs/gst_env/bin/clang2py", line 5, in from ctypeslib.clang2py import main File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/site-packages/ctypeslib/init.py", line 101, in if clang_version().split('.')[0] != clang_py_version().split('.')[0]: File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/site-packages/ctypeslib/init.py", line 56, in clang_version get_version = cindex.conf.get_cindex_library().clang_getClangVersion File "/home/muratbal/anaconda3/envs/gst_env/lib/python3.9/site-packages/clang/cindex.py", line 4178, in get_cindex_library raise LibclangError(msg) clang.cindex.LibclangError: /home/muratbal/anaconda3/envs/gst_env/lib/clang: cannot read file data: Is a directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

murat-bal avatar Apr 16 '23 19:04 murat-bal

I'm not familiar with how anaconda packages libraries. @murat-bal what is your OS ? What is the content of home/muratbal/anaconda3/envs/gst_env/lib/clang ? I'll push a generic fix

trolldbois avatar Apr 17 '23 22:04 trolldbois

@murat-bal would you be able to pip install git+https://github.com/trolldbois/ctypeslib.git to see if the patch I pushed fixes your issue ? it seems that on your platform, the ctypes.util.find_library returns a library folder path, and not a specific filename. which is possible as per documentation https://docs.python.org/3/library/ctypes.html#finding-shared-libraries

trolldbois avatar Apr 17 '23 22:04 trolldbois

@murat-bal would you be able to re-try ?

pip install ctypeslib2 clang==14

or whatever version of clang you are using .

trolldbois avatar Apr 25 '23 00:04 trolldbois