JulianEberius / SublimeRope

ST2 only, use SublimePythonIDE with ST3: Adds Python completions and some IDE-like functions to Sublime Text 2, through the use of the Rope library
GNU General Public License v2.0
250 stars 26 forks source link

SublimeRope fails to recognize modules #40

Closed mandx closed 11 years ago

mandx commented 12 years ago

I usually add this to the SublimeRope config:

    prefs.add('python_path', '/usr/lib/python2.7/')
    prefs.add('python_path', '/home/mandx/projects/test_project_root/test_project')
    prefs.add('python_path', '/home/mandx/projects/test_project_root/env/lib/python2.7/')
    prefs.add('python_path', '/home/mandx/projects/test_project_root/env/lib/python2.7/site-packages')

But SublimeRope fails to find modules and symbols. In the SublimeText console, I get this:

Writing file /home/mandx/projects/freespear/test_project_root/.ropeproject/config.py with encoding UTF-8
Traceback (most recent call last):
  File "./sublime_plugin.py", line 236, in on_query_completions
  File "./sublime_rope.py", line 70, in on_query_completions
    maxfixes=3, later_locals=False)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/contrib/codeassist.py", line 33, in code_assist
    return assist()
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/contrib/codeassist.py", line 325, in __call__
    completions = list(self._code_completions().values())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/contrib/codeassist.py", line 408, in _code_completions
    self._undotted_completions(inner_scope, result, lineno=lineno)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/contrib/codeassist.py", line 351, in _undotted_completions
    names = scope.get_names()
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyscopes.py", line 16, in get_names
    return self.pyobject.get_attributes()
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyobjects.py", line 196, in get_attributes
    result = dict(self._get_concluded_attributes())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyobjects.py", line 191, in _get_concluded_attributes
    self.concluded_attributes.set(self._create_concluded_attributes())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 127, in _create_concluded_attributes
    for base in reversed(self.get_superclasses()):
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 119, in get_superclasses
    self._superclasses.set(self._get_bases())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pyobjectsdef.py", line 137, in _get_bases
    base.get_object().get_type() == get_base_type('Type'):
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pynames.py", line 158, in get_object
    return self._get_imported_pyname().get_object()
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pynames.py", line 149, in _get_imported_pyname
    result = self.imported_module.get_object()[self.imported_name]
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pynames.py", line 130, in get_object
    if self._get_pymodule() is None:
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pynames.py", line 120, in _get_pymodule
    self._current_folder())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pycore.py", line 79, in get_module
    pymod = self._builtin_module(name)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pycore.py", line 97, in _builtin_module
    return self.extension_cache.get_pymodule(name)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pycore.py", line 345, in get_pymodule
    allowed = self.pycore.extension_modules
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/utils.py", line 10, in _wrapper
    setattr(self, name, func(self, *args, **kwds))
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/pycore.py", line 295, in extension_modules
    result.update(stdmods.dynload_modules())
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/utils.py", line 74, in __call__
    result = self.func(*args, **kwds)
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/stdmods.py", line 39, in dynload_modules
    dynload_path = os.path.join(_stdlib_path(), 'lib-dynload')
  File "/home/mandx/.config/sublime-text-2/Packages/SublimeRope/rope/base/stdmods.py", line 9, in _stdlib_path
    import distutils.sysconfig
  File "/home/mandx/projects/freespear/test_project_root/env/lib/python2.7/distutils/__init__.py", line 16, in <module>
    exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 20] Not a directory: '/usr/lib/sublime-text-2/lib/python26.zip/distutils/__init__.py'

And /usr/lib/sublime-text-2/lib/python26.zip is a ZIP file, provided by ST2.

What's wrong? Should I tell ST2 to use my system Python? (I'm using Ubuntu 11.10). What else can I see to debug this?

I'm using this ST2 version (executed this in the console):

>>> sublime.version()
u'2217'
DamnWidget commented 12 years ago

Hi @mandx,

Since the latest SublimeRope version we have a better way to have our completions working.

Take a red to this https://github.com/JulianEberius/SublimeRope#basic-usage

Greetings!

mandx commented 12 years ago

I'm already using the latest version of SublimeRope (using PackageControl) :)

The issue here is some SublimeRope projects work, and other projects don't. I'm using the default settings, and I only adjust the module path in a per project basis.

2012/7/28, Oscar Campos reply@reply.github.com:

Hi @mandx,

Since the latest SublimeRope version we have a better way to have our completions working.

Take a red to this https://github.com/JulianEberius/SublimeRope#basic-usage

Greetings!


Reply to this email directly or view it on GitHub: https://github.com/JulianEberius/SublimeRope/issues/40#issuecomment-7336206

creitve commented 12 years ago

Hello, I am having the same issue:

key evt: control+keypad0
command: goto_python_definition
IOError: [Errno 20] Not a directory: '/usr/lib/sublime-text-2/lib/python26.zip/distutils/__init__.py'

I am using the latest Package Control version.

JulianEberius commented 12 years ago

Hi,

Sorry for replying that late, but SublimeRope is a free-time project after all ;-) There seems to be a problem with how Rope tries to determine the Python standard libraries path (using the distribute module, see stdmods.py) and how ST2 ships this standard lib (as a zip). I commited a possible fix, but I have no Linux machine with ST2 to test it. Please update and report if the fix solved your problem!

Thank you, Julian

JulianEberius commented 11 years ago

Since nobody replied with further problems, I'm closing this issue.