title: Why can't this python script find the libclang dll?
body: <p>I would like to get started with using <strong>libclang</strong> with <strong>Python</strong>. I am trying to get a sample code (<a href="http://www.altdevblogaday.com/2014/03/05/implementing-a-code-generator-with-libclang/" rel="noreferrer">http://www.altdevblogaday.com/2014/03/05/implementing-a-code-generator-with-libclang/</a>) to work on <strong>Windows</strong>, here is a part of the code I'm trying to run:</p>
  
  <pre><code>#!/usr/bin/python
  # vim: set fileencoding=utf-8
  
  import sys
  import os
  import clang.cindex
  import itertools
  
  ...
  
  print("Setting clang path")
  # I tried multiple variations. Libclang is correctly installed in the specified location.
  #clang.cindex.Config.set_library_path('C:/Program Files (x86)/LLVM/bin')
  #clang.cindex.Config.set_library_path('C:/Program Files (x86)/LLVM/bin/libclang.dll')
  
  # I also tried moving the dll into the Python installation folder.
  clang.cindex.Config.set_library_file('C:/Python27/DLLs/libclang.dll')
  print("Clang path set")
  
  index = clang.cindex.Index.create()
  
  ...
  </code></pre>
  
  <p>I stripped all the other parts of the code, but I can post them if they are relevant. The line</p>
  
  <pre><code>index = clang.cindex.Index.create()
  </code></pre>
  
  <p>Throws the following error:</p>
  
  <pre><code>Setting clang path
  Clang path set
  Traceback (most recent call last):
    File "D:\libclangtest\boost_python_gen.py", line 60, in &lt;module&gt;
      index = clang.cindex.Index.create()
    File "D:\libclangtest\clang\cindex.py", line 2095, in create
      return Index(conf.lib.clang_createIndex(excludeDecls, 0))
    File "D:\libclangtest\clang\cindex.py", line 141, in __get__
      value = self.wrapped(instance)
    File "D:\libclangtest\clang\cindex.py", line 3392, in lib
      lib = self.get_cindex_library()
    File "D:\libclangtest\clang\cindex.py", line 3423, in get_cindex_library
      raise LibclangError(msg)
  clang.cindex.LibclangError: [Error 193] %1 is not a valid Win32 application. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().
  </code></pre>
  
  <p>What is the reason for this? Am I setting the dll's path wrong? I tried multiple ways, with foreslashes and backslashes, I also tried to move the dll out of Program Files to make the path contain no spaces, but nothing worked.</p>
  
  <p>I am a total beginner to libclang and Python, sry if I'm asking something trivial.</p>