Skip to content

No Module named Clang #1

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

Open
natet opened this issue Jan 19, 2016 · 7 comments
Open

No Module named Clang #1

natet opened this issue Jan 19, 2016 · 7 comments
Assignees
Milestone

Comments

@natet
Copy link

natet commented Jan 19, 2016

I am running ST3 build 3095 on Windows 10 with LLVM 3.6.1. When I load up ST3, I get the following error in the console:

reloading plugin clangHelper.codeCompletion
Traceback (most recent call last):
File "C:\Users\Nathan\AppData\Roaming\Sublime Text 3\Packages\clangHelper\codeCompletion.py", line 15, in
from clang.cindex import TranslationUnit
ImportError: No module named 'clang'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 74, in reload_plugin
m = importlib.import_module(modulename)
File "./importlib/init.py", line 90, in import_module
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module
File "", line 313, in _call_with_frames_removed
File "C:\Users\Nathan\AppData\Roaming\Sublime Text 3\Packages\clangHelper\codeCompletion.py", line 19, in
if get_libclang_version() == '32':
File "C:\Users\Nathan\AppData\Roaming\Sublime Text 3\Packages\clangHelper\tools\libclang_version.py", line 19, in get_libclang_version
lib = CDLL(lib_file)
File "./ctypes/init.py", line 353, in init
OSError: [WinError 193] %1 is not a valid Win32 application

@griebd
Copy link
Owner

griebd commented Jan 19, 2016

Strange, you got a exception in a try block...
Anyway, could you try commenting lines 14 to 32 except by line 28 (your version of LLVM) removing the indentation. something like:

# try:
#     from clang.cindex import TranslationUnit
# # use customized clang python bindings
# except:
#     from clangHelper.tools.libclang_version import get_libclang_version
#     if get_libclang_version() == '32':
#         from clangHelper.clang.cindex32 import TranslationUnit
#     if get_libclang_version() == '33':
#         from clangHelper.clang.cindex33 import TranslationUnit
#     if get_libclang_version() == '34':
#         from clangHelper.clang.cindex34 import TranslationUnit
#     if get_libclang_version() == '35':
#         from clangHelper.clang.cindex35 import TranslationUnit
#     if get_libclang_version() == '36':
from clangHelper.clang.cindex36 import TranslationUnit
#     elif get_libclang_version() == '37':
#         from clangHelper.clang.cindex37 import TranslationUnit
#     if get_libclang_version() == '38':
#         from clangHelper.clang.cindex38 import TranslationUnit

and then report back please. Thanks.

@griebd
Copy link
Owner

griebd commented Jan 19, 2016

Another thing, your system is 64bits right? ST and LLVM are too? Or is LLVM 32bits for example?

@griebd griebd added the Windows label Jan 19, 2016
@griebd griebd self-assigned this Jan 19, 2016
@griebd
Copy link
Owner

griebd commented Jan 19, 2016

run this on your sublime console and send the results back, please:

import sublime; from sys import version; from platform import platform; from struct import calcsize; print('Sublime:'); print('\tversion:', sublime.version()); print('\tplatform:', sublime.platform()); print('\tarch:', sublime.arch()); print('python:'); print('\tversion:', version); print('\tplatform:', platform()); print('\tarch:', 8 * calcsize("P"))

@natet
Copy link
Author

natet commented Jan 19, 2016

I was using a 32 bit version of clang (the only binaries for 3.6.2 are 32 bit). I've since installed the 64 bit version of 3.7.1. I'll post the results of the other 2 suggestions shortly.

@natet
Copy link
Author

natet commented Jan 19, 2016

Sublime:
version: 3095
platform: windows
arch: x64

I'm getting closer. After commenting out the lines you suggested, the plugin does load. But, when attempting to do a completion, an error dialog popped up. I can't get it to do it now. What I get in the console is:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 359, in on_query_completions
res = callback.on_query_completions(v, prefix, locations)
File "C:\Users\Nathan\AppData\Roaming\Sublime Text 3\Packages\clangHelper\codeCompletion.py", line 163, in on_query_completions
cr = self.translation_units[view.id()].codeComplete(
KeyError: 16

@griebd griebd added the bug label Jan 20, 2016
@griebd
Copy link
Owner

griebd commented Jan 20, 2016

ok, your first error was because the 32bits LLVM! ctypes, the lib used by python to load LLVM, can't load libs if the architecture mismatch...

but now you have an error in my code, you probably found a bug...
if you close this view and reopen and try again the error persist?! if yes, the last line changed? The one that says "KeyError: xx".

@griebd griebd added this to the 0.1.0 milestone Jan 20, 2016
@griebd
Copy link
Owner

griebd commented Jan 20, 2016

Another test would be to right click the view and select 'clangHelper' -> 'Clear all settings on this view', then close and reopen Sublime itself.

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

No branches or pull requests

2 participants