My plugin (currently a single command) needs to make use of the chardet Python library. I have therefore put a copy of the chardet module in a subdirectory of my package:
- Packages[list]]My Package[list]]my_command.py
- chardet[list]*]init.py
- big5freq.py
- …
/:m][/list:u]/:m][/list:u]/*:m][/list:u]
Now, inside my_command.py, I import and attempt to use chardet:
[code]import chardet
…
class MyCommandCommand(sublime_plugin.TextCommand):
def run(self, edit):
…
decoded_content = content.decode(chardet.detect(content)‘encoding’])[/code]
When Sublime Text 2’s Python attempts to run chardet.detect, it fails with this error:
Traceback (most recent call last):
File "./sublime_plugin.py", line 255, in run_
File "./lookup_with_google_and_link.py", line 79, in run
File "./lookup_with_google_and_link.py", line 50, in get_link_with_title
File "./chardet/__init__.py", line 21, in detect
ImportError: No module named universaldetector
The universaldetector.py file exists in the chardet directory. I can see that Python is creating a init.pyc file for init.py, but no .pyc files for any of the other files under chardet.
If I open my system Python interpreter in my My Package directory, I can import and use chardet.detect without incident.
Any idea what could be causing this?