- Packages
- My Package
- my_command.py
- chardet
- __init__.py
- big5freq.py
- …
- My Package
Now, inside my_command.py, I import and attempt to use chardet:
- Code: Select all
import chardet
…
class MyCommandCommand(sublime_plugin.TextCommand):
def run(self, edit):
…
decoded_content = content.decode(chardet.detect(content)['encoding'])
When Sublime Text 2’s Python attempts to run chardet.detect, it fails with this error:
- Code: Select all
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?