Repository: davidhalter/jedi

Issue #471: ImportError during call_signatures
Created: 2014-08-27T07:51:02Z
A user of Elpy reports in jorgenschaefer/elpy#337

I have some projects that use fortran and c accelerated routines. It appears that when Jedi tries to look at these while editing code, the elpy bug report keeps popping up.

Traceback (most recent call last):
  File "/home/user/.emacs.d/elpa/elpy-20140810.7/elpy/jedibackend.py", line 235, in run_with_debug
    return getattr(script, name)()
  File "/home/user/.local/lib/python2.7/site-packages/jedi/api/__init__.py", line 574, in call_signatures
    self._pos, user_stmt)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/cache.py", line 90, in wrapper
    value = optional_callable()
  File "/home/user/.local/lib/python2.7/site-packages/jedi/api/__init__.py", line 572, in <lambda>
    _callable = lambda: self._evaluator.eval_call(stmt_el)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/__init__.py", line 226, in eval_call
    return self.eval_call_path(path, par, s.start_pos)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/__init__.py", line 244, in eval_call_path
    types = imports.follow_imports(self, types)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 482, in follow_imports
    for r in ImportWrapper(evaluator, s).follow():
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 171, in follow
    module, rest = self._importer.follow_file_system()
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/cache.py", line 39, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 365, in follow_file_system
    module, rest = self._follow_sys_path(sys_path_mod)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 469, in _follow_sys_path
    return _load_module(path, source, sys_path=sys_path), rest
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 527, in _load_module
    return load(source) if cached is None else cached.module
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 520, in load
    return compiled.load_module(path, name)
  File "/home/user/.local/lib/python2.7/site-packages/jedi/evaluate/compiled/__init__.py", line 288, in load_module
    __import__(dotted_path)
ImportError: No module named f2pymodule

Jedi Debug Information

[N] dbg: finder.filter_name "f2pymodule" in (<Function: routine@752-790>-<ModuleWrapper: <fast.Module: mainpymodule@1-4752>>): [<Name: f2pymodule@23,7>]@(771, 8)
[N] dbg: finder._names_to_types: [<Name: f2pymodule@23,7>] -> [<Import: import f2pymodule @23,0>]
[N] dbg: follow_module None f2pymodule
[N] dbg: search_module /home/usr/lib/python

Lacking the self-written modules, I can't provide reproduction steps I'm afraid.

Duplicate issue #468: linter crashes on module that import `socket`
Created: 2014-08-20T07:11:47Z
Steps to reproduce on my machine:
$ virtualenv-2.6 /tmp/jedi-test
New python executable in /tmp/jedi-test/bin/python2.6
Also creating executable in /tmp/jedi-test/bin/python
Installing setuptools, pip...done.
$ /tmp/jedi-test/bin/pip install jedi
Downloading/unpacking jedi
  Running setup.py (path:/tmp/jedi-test/build/jedi/setup.py) egg_info for package jedi
    warning: no previously-included files matching '*.pyc' found under directory '*'
Installing collected packages: jedi
  Running setup.py install for jedi
    warning: no previously-included files matching '*.pyc' found under directory '*'
Successfully installed jedi
Cleaning up...
$ echo "import socket" > /tmp/jedi-test.py
$ /tmp/jedi-test/bin/python -m jedi.__main__ linter /tmp/jedi-test.py
Traceback (most recent call last):
  File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/__main__.py", line 36, in <module>
    for error in jedi.Script(path=path)._analysis():
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/api/__init__.py", line 596, in _analysis
    nested_resolve=True).follow()
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 181, in follow
    star_imports = remove_star_imports(self._evaluator, module)
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/cache.py", line 171, in wrapper
    mods = func(evaluator, scope, *args, **kwargs)
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 500, in remove_star_imports
    modules = follow_imports(evaluator, (i for i in scope.get_imports() if i.star))
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 482, in follow_imports
    for r in ImportWrapper(evaluator, s).follow():
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 171, in follow
    module, rest = self._importer.follow_file_system()
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/cache.py", line 39, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 365, in follow_file_system
    module, rest = self._follow_sys_path(sys_path_mod)
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 469, in _follow_sys_path
    return _load_module(path, source, sys_path=sys_path), rest
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 527, in _load_module
    return load(source) if cached is None else cached.module
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/imports.py", line 520, in load
    return compiled.load_module(path, name)
  File "/tmp/jedi-test/lib/python2.6/site-packages/jedi/evaluate/compiled/__init__.py", line 288, in load_module
    __import__(dotted_path)
ImportError: dynamic module does not define init function (init_socketmodule)
$ /tmp/jedi-test/bin/pip freeze
jedi==0.8.1-final0
wsgiref==0.1.2

I would have expected /tmp/jedi-test.py to have validated cleanly.

Closing comment (2015-03-06T00:50:50Z): Looks very similar to #471.