0

I have installed the clang python library on windows. When I'm executing a script that uses it, It gives me this:

Could not find module 'path\to\clang\libclang.dll' (or one of its dependencies). Try using the full path with constructor syntax.. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

Despite the fact that I included in my code

from clang.cindex import Config 
Config.set_library_path('path/to/clang/libclang.dll') 

when I checked the path of clang, I couldn't find ibclang.dll or ibclang.so. Does anyone know how can I solve this?

Shaheen
  • 31
  • 6
  • have you tried using an absolute path rather than a relative one in `set_library_path`? – Alan Birtles Oct 06 '22 at 09:17
  • @AlanBirtles, I'm using an absolute path. I think the problem is that the file `libclang.dll` can't be found under the clang folder. – Shaheen Oct 06 '22 at 09:51

1 Answers1

2

You need to build clang and get the libclang.dll, the pre-built version can be downloaded here.

Put libclang.dll into the same directory as your script and do this:

import os

scriptDir = os.path.dirname(os.path.realpath(__file__))
cindex.Config.set_library_path(scriptDir)
thedemons
  • 1,139
  • 2
  • 9
  • 25