Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
murat-bal opened this issue Apr 16, 2023 · 3 comments
Assignees
Labels
bug Confirmed bug

Comments

@murat-bal
Copy link

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().

@trolldbois
Copy link
Owner

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
Copy link
Owner

@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 trolldbois added the bug Confirmed bug label Apr 17, 2023
@trolldbois trolldbois self-assigned this Apr 17, 2023
@trolldbois
Copy link
Owner

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

pip install ctypeslib2 clang==14

or whatever version of clang you are using .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants