I just pip installed clang to my Anaconda Python 3 installation and I'm unable to import the clang python bindings...
C:\Temp>python -m pip install clang --proxy="xxxxx"
Collecting clang
Downloading clang-3.8.tar.gz
Building wheels for collected packages: clang
Running setup.py bdist_wheel for clang ... done
Stored in directory: C:\xxxxxx
Successfully built clang
Installing collected packages: clang
Successfully installed clang-3.8
C:\Temp>python
>>> import clang.cindex
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\clang\cindex.py", line 515
raise ValueError,'{0} value {1} already loaded'.format(
^
SyntaxError: invalid syntax
I am however able to successfully import clang by itself, although not with anything useful...
>>> import clang
>>> clang.
clang.__all__ clang.__loader__ clang.__spec__ clang.__dir__( clang.__getattribute__( clang.__le__( clang.__reduce__( clang.__sizeof__(
clang.__cached__ clang.__name__ clang.__class__( clang.__eq__( clang.__gt__( clang.__lt__( clang.__reduce_ex__( clang.__str__(
clang.__doc__ clang.__package__ clang.__delattr__( clang.__format__( clang.__hash__( clang.__ne__( clang.__repr__( clang.__subclasshook__(
clang.__file__ clang.__path__ clang.__dict__ clang.__ge__( clang.__init__( clang.__new__( clang.__setattr__(
Looking at the source file where the exception is thrown appears to suggest it may be a Python3 syntax issue...
### Cursor Kinds ###
class BaseEnumeration(object):
"""
Common base class for named enumerations held in sync with Index.h values.
Subclasses must define their own _kinds and _name_map members, as:
_kinds = []
_name_map = None
These values hold the per-subclass instances and value-to-name mappings,
respectively.
"""
def __init__(self, value):
if value >= len(self.__class__._kinds):
self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
if self.__class__._kinds[value] is not None:
raise ValueError,'{0} value {1} already loaded'.format( #<--Py2 Syntax str(self.__class__), value)
self.value = value
self.__class__._kinds[value] = self
self.__class__._name_map = None
Looking at the rest of cindex.py seems consistent that the libclang bindings have not yet been developed for Python3. Is that accurate or did my pip or something else get mixed up during the install?
Looks like it was a Py2/3 syntax issue, luckily I was able to run 2to3.exe on the folder
C:\Anaconda3\Lib\site-packages\clang
and merge over the fixesNow I'm in business...