ImportError: No module named 'jsbeautifier.core'
Opened this issue · 7 comments
Getting an error on ST3 load, couldn't find another open or closed issue dealing with this.
Running osx high seirra, let me know if there is any other helpful info i can give.
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 109, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/__init__.py", line 90, in import_module
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1022, in load_module
File "<frozen importlib._bootstrap>", line 1003, in load_module
File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 868, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/Users/eboney/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/CodeFormatter.py", line 26, in <module>
from .codeformatter.formatter import Formatter
File "/Users/eboney/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/formatter.py", line 22, in <module>
from .cssformatter import CssFormatter
File "/Users/eboney/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/cssformatter.py", line 7, in <module>
import cssbeautifier
File "/Users/eboney/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/cssbeautifier/__init__.py", line 32, in <module>
from cssbeautifier.css.beautifier import Beautifier
File "/Users/eboney/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/cssbeautifier/css/beautifier.py", line 6, in <module>
from jsbeautifier.core.options import mergeOpts
ImportError: No module named 'jsbeautifier.core'
@thecotne could you test this on your MAC?
FWIW, I get this on MacOS X Sierra (10.12.6) running SublimeText 3.0 build 3143.
reloading plugin CodeFormatter.CodeFormatter
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 109, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/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 "/Users/jim.jarrett/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/CodeFormatter.py", line 26, in
from .codeformatter.formatter import Formatter
File "/Users/jim.jarrett/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/formatter.py", line 22, in
from .cssformatter import CssFormatter
File "/Users/jim.jarrett/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/cssformatter.py", line 7, in
import cssbeautifier
File "/Users/jim.jarrett/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/cssbeautifier/init.py", line 32, in
from cssbeautifier.css.beautifier import Beautifier
File "/Users/jim.jarrett/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/cssbeautifier/css/beautifier.py", line 6, in
from jsbeautifier.core.options import mergeOpts
ImportError: No module named 'jsbeautifier.core'
MacOS High Sierra 10.13.2
ST3 (3.0, Build 3143)
reloading plugin CodeFormatter.CodeFormatter
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 109, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/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 "/Users/info/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/CodeFormatter.py", line 26, in
from .codeformatter.formatter import Formatter
File "/Users/info/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/formatter.py", line 23, in
from .scssformatter import ScssFormatter
File "/Users/info/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/scssformatter.py", line 6, in
import scssbeautifier
File "/Users/info/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/scssbeautifier/init.py", line 31, in
from cssbeautifier.css.options import BeautifierOptions
ImportError: No module named 'cssbeautifier.css'
MacOS High Sierra 10.13.2
ST3 (3.0, Build 3143)
reloading plugin CodeFormatter.CodeFormatter
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 109, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/__init__.py", line 90, in import_module
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1022, in load_module
File "<frozen importlib._bootstrap>", line 1003, in load_module
File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 868, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/Users/lucacappelletti/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/CodeFormatter.py", line 26, in <module>
from .codeformatter.formatter import Formatter
File "/Users/lucacappelletti/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/formatter.py", line 23, in <module>
from .scssformatter import ScssFormatter
File "/Users/lucacappelletti/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/scssformatter.py", line 6, in <module>
import scssbeautifier
File "/Users/lucacappelletti/Library/Application Support/Sublime Text 3/Packages/CodeFormatter/codeformatter/lib/scssbeautifier/__init__.py", line 31, in <module>
from cssbeautifier.css.options import BeautifierOptions
ImportError: No module named 'cssbeautifier.css'
For the time being I've resolved by disabling the scss package and setting chmod +x to the codeformatter directory.
# @author Avtandil Kikabidze
# @copyright Copyright (c) 2008-2015, Avtandil Kikabidze aka LONGMAN (akalongman@gmail.com)
# @link http://longman.me
# @license The MIT License (MIT)
import os
import sys
import re
import sublime
directory = os.path.dirname(os.path.realpath(__file__))
libs_path = os.path.join(directory, 'lib')
if libs_path not in sys.path:
sys.path.append(libs_path)
try:
# Python 3
from .phpformatter import PhpFormatter
from .jsformatter import JsFormatter
from .htmlformatter import HtmlFormatter
from .cssformatter import CssFormatter
# from .scssformatter import ScssFormatter
from .pyformatter import PyFormatter
from .vbscriptformatter import VbscriptFormatter
from .coldfusionformatter import ColdfusionFormatter
except (ValueError):
# Python 2
from phpformatter import PhpFormatter
from jsformatter import JsFormatter
from htmlformatter import HtmlFormatter
from cssformatter import CssFormatter
from scssformatter import ScssFormatter
from pyformatter import PyFormatter
from vbscriptformatter import VbscriptFormatter
from coldfusionformatter import ColdfusionFormatter
class Formatter:
def __init__(self, view, syntax=None):
self.platform = sublime.platform()
self.classmap = {}
self.st_version = 2
if sublime.version() == '' or int(sublime.version()) > 3000:
self.st_version = 3
self.file_name = view.file_name()
self.settings = sublime.load_settings('CodeFormatter.sublime-settings')
self.packages_path = sublime.packages_path()
self.syntax_file = view.settings().get('syntax')
self.syntax = syntax or self.get_syntax()
# map of settings names with related class
map_settings_formatter = [
('codeformatter_php_options', PhpFormatter),
('codeformatter_js_options', JsFormatter),
('codeformatter_css_options', CssFormatter),
('codeformatter_html_options', HtmlFormatter),
('codeformatter_python_options', PyFormatter),
('codeformatter_vbscript_options', VbscriptFormatter),
# ('codeformatter_scss_options', ScssFormatter),
('codeformatter_coldfusion_options', ColdfusionFormatter),
]
for name, _class in map_settings_formatter:
syntaxes = self.settings.get(name, {}).get('syntaxes')
if not syntaxes or not isinstance(syntaxes, str):
continue
for _formatter in syntaxes.split(','):
self.classmap[_formatter.strip()] = _class
def format(self, text):
formatter = self.classmap[self.syntax](self)
try:
stdout, stderr = formatter.format(text)
except Exception as e:
stdout = ''
stderr = str(e)
return self.clean(stdout), self.clean(stderr)
def exists(self):
return self.syntax in self.classmap
def get_syntax(self):
pattern = re.compile(
r'Packages/.*/(.+?).(?=tmLanguage|sublime-syntax)')
m = pattern.search(self.syntax_file)
found = ''
if m and len(m.groups()) > 0:
found = m.groups()[0]
return found.lower()
def format_on_save_enabled(self):
if not self.exists():
return False
formatter = self.classmap[self.syntax](self)
return formatter.format_on_save_enabled(self.file_name)
def clean(self, string):
if hasattr(string, 'decode'):
string = string.decode('UTF-8', 'ignore')
return re.sub(r'\r\n|\r', '\n', string)
win10_17063
sublime text 3(3126)
reloading plugin CodeFormatter.CodeFormatter
Traceback (most recent call last):
File "C:\Asofts\sublimetext3\sublime_plugin.py", line 109, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/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:\Asofts\sublimetext3\Data\Packages\CodeFormatter\CodeFormatter.py", line 26, in
from .codeformatter.formatter import Formatter
File "C:\Asofts\sublimetext3\Data\Packages\CodeFormatter\codeformatter\formatter.py", line 23, in
from .scssformatter import ScssFormatter
File "C:\Asofts\sublimetext3\Data\Packages\CodeFormatter\codeformatter\scssformatter.py", line 6, in
import scssbeautifier
File "C:\Asofts\sublimetext3\Data\Packages\CodeFormatter\codeformatter\lib\scssbeautifier_init.py", line 31, in
from cssbeautifier.css.options import BeautifierOptions
ImportError: No module named 'cssbeautifier.css'
python install infor about
C:\Users\vic>pip show jsbeautifier
Name: jsbeautifier
Version: 1.7.5
Summary: JavaScript unobfuscator and beautifier.
Home-page: http://jsbeautifier.org
Author: Einar Lielmanis, Stefano Sanfilippo et al.
Author-email: einar@jsbeautifier.org
License: MIT
Location: c:\asofts\python3\lib\site-packages
Requires: six, editorconfig
C:\Users\vic>
is there another way to fix it ?I do not want to edit CodeFormatter.py as LucaCappelletti94
It's an issue related to how the plugin imports its files. For example, I believe that in the scss plugin it tries to import the wrong folder (the css one) instead of its /css folder.
If I manage to understand how to fix imports I'll fork and push my fix to this repository.