ImportError: No module named vdebug #93

Closed
boxofrox opened this Issue Jun 13, 2013 · 9 comments

Projects

None yet

2 participants

@boxofrox

When starting vim I get the error:

$ vim
Error detected while processing /home/charetjc/.vim/bundle/vdebug/plugin/vdebug.vim:
line   40:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py", line 12, in <module>
    import vdebug.runner
ImportError: No module named vdebug
line  111:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'DebuggerInterface' is not defined
Press ENTER or type command to continue

I have Vim 7.3.1163 using Python 2.7.3. I tried pulling the latest version of vdebug from master to no effect. I'm not familiar with python, so what follows is an ignorant investigation based on my familiarity troubleshooting other languages I know.

Since vim/python cannot find the vdebug module, it seems the problem may lie with the sys.path. I modified start_vdebug.py to print the sys.path.

$ vim
Error detected while processing /home/charetjc/.vim/bundle/vdebug/plugin/vdebug.vim:
line   40:
directory: /home/charetjc/.vim/bundle/vdebug/plugin/python
sys.path:
    /usr/lib64/python27.zip
    /usr/lib64/python2.7
    /usr/lib64/python2.7/plat-linux2
    /usr/lib64/python2.7/lib-tk
    /usr/lib64/python2.7/lib-old
    /usr/lib64/python2.7/lib-dynload
    /usr/lib64/python2.7/site-packages
    /usr/lib64/python2.7/site-packages/PIL
    /usr/lib64/python2.7/site-packages/gtk-2.0
    /usr/lib64/portage/pym
    _vim_path_
    /home/charetjc/.vim/bundle/vdebug/plugin/python
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py", line 12, in <module>
    import vdebug.runner
ImportError: No module named vdebug
line  111:
...
Press ENTER or type command to continue

That 'vim_path' seems invalid. I'm not sure whence it came. Popping it from the sys.path only led me to an anonymous error.

$ vim
Error detected while processing /home/charetjc/.vim/bundle/vdebug/plugin/vdebug.vim:
line   40:
directory: /home/charetjc/.vim/bundle/vdebug/plugin/python
sys.path:
    /usr/lib64/python27.zip
    /usr/lib64/python2.7
    /usr/lib64/python2.7/plat-linux2
    /usr/lib64/python2.7/lib-tk
    /usr/lib64/python2.7/lib-old
    /usr/lib64/python2.7/lib-dynload
    /usr/lib64/python2.7/site-packages
    /usr/lib64/python2.7/site-packages/PIL
    /usr/lib64/python2.7/site-packages/gtk-2.0
    /usr/lib64/portage/pym
    /home/charetjc/.vim/bundle/vdebug/plugin/python
Press ENTER or type command to continue

Not sure where to go from here. Any suggestions are welcome. I will explore this more a bit later.

@joonty
Owner
joonty commented Jun 13, 2013

Hmm, strange. The path thing is definitely one issue, as the vdebug python path should be there.

Try running

:pyfile /home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py

And see whether that gives you a more helpful error message.

@boxofrox

Without popping sys.path:

# vim output of :pyfile /home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py

directory: /home/charetjc/.vim/bundle/vdebug/plugin/python
sys.path: 
    ...same as before...
    /usr/lib64/portage/pym
    _vim_path_
    /home/charetjc/.vim/bundle/vdebug/plugin/python
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py", line 12, in <module>
    import vdebug.runner
ImportError: No module named vdebug

After popping sys.path:

# vim output of :pyfile /home/charetjc/.vim/bundle/vdebug/plugin/python/start_vdebug.py

directory: /home/charetjc/.vim/bundle/vdebug/plugin/python
sys.path: 
    ...same as before...
    /usr/lib64/portage/pym
    /home/charetjc/.vim/bundle/vdebug/plugin/python

No error... so if I remove my sys.stderr.writes from start_vdebug.py, vim starts up with no errors.
Hurray.

Now I just need to figure out where that stupid 'vim_path' came from. But that's likely an issue with something else on my system. If you agree, go ahead and close this issue. If I figure out where 'vim_path' originated, I'll post an update.

Thanks, joonty, for the pyfile suggestion.

@boxofrox

If anyone is curious about the modifications I made to start_vdebug.py to troubleshoot this. Here's a git diff.

diff --git a/plugin/python/start_vdebug.py b/plugin/python/start_vdebug.py
index 9a93c36..c3d9542 100644
--- a/plugin/python/start_vdebug.py
+++ b/plugin/python/start_vdebug.py
@@ -3,7 +3,10 @@ import os
 import inspect

 directory = os.path.dirname(inspect.getfile(inspect.currentframe()))
+sys.path.pop()
 sys.path.append(directory)
+#sys.stderr.write('directory: %s\n' % directory)
+#sys.stderr.write('sys.path: \n    %s\n' % '\n    '.join(sys.path))

 import socket
 import traceback
@boxofrox

Looks like the culprit is a recent vim patch to support python3 and will cause problems for python2.7 plugins that modify sys.path. Vim 7.3.1183 may fix this.

https://groups.google.com/forum/?fromgroups#!topic/vim_dev/6INEeAi8khs

@joonty
Owner
joonty commented Jun 17, 2013

@boxofrox thanks a lot for your research into that, it's really valuable. I'll get a fix for this hopefully this week.

Thanks

@boxofrox

my pleasure. it's the least I can do. I've found vdebug very useful.
thanks for taking the time to develop and release it. :)

On Mon, Jun 17, 2013 at 5:17 AM, Jonathan Cairns
notifications@github.comwrote:

@boxofrox https://github.com/boxofrox thanks a lot for your research
into that, it's really valuable. I'll get a fix for this hopefully this
week.

Thanks


Reply to this email directly or view it on GitHubhttps://github.com/joonty/vdebug/issues/93#issuecomment-19541242
.

@joonty
Owner
joonty commented Jun 27, 2013

Hi,

Just a clarification on this. Am I right in thinking that this affects a certain small set of versions of Vim, and is fixed in an upcoming release?

I'm trying to work out exactly how to handle this, as it could be a very dangerous patch to apply. I don't want to break it for existing users! But if it is only for a certain version set, I can safely apply a fix for that.

Thanks

@boxofrox

From that mailing list thread I linked, I got the impression the devs are
aware that their vim_path modification will break python-2 plugins that
modify sys.path. I posted to that thread, mentioned issue #93, and asked
for clarification whether Bram's last patch solved this issue. I haven't
received an answer since June 16, and after reviewing Bram's patch, it
seems some unit tests were modified to pass. So afaik, this bug is still
active.

I wouldn't rush toward a fix for this in vdebug. Open a discussion with
the vim devs about this issue if you can. My modifications provide a
sufficient work-around in the interim until vim or vdebug can correctly
handle the issue.

As I upgrade my vim, I'll revisit this issue and see whether it's fixed and
update the issue tracker.

On Thu, Jun 27, 2013 at 5:55 AM, Jonathan Cairns
notifications@github.comwrote:

Hi,

Just a clarification on this. Am I right in thinking that this affects a
certain small set of versions of Vim, and is fixed in an upcoming release?

I'm trying to work out exactly how to handle this, as it could be a very
dangerous patch to apply. I don't want to break it for existing users! But
if it is only for a certain version set, I can safely apply a fix for that.

Thanks


Reply to this email directly or view it on GitHubhttps://github.com/joonty/vdebug/issues/93#issuecomment-20116492
.

@boxofrox

I updated my package cache and installed vim 7.3.1214, removed my modifications, and this issue is fixed in vim.

@boxofrox boxofrox closed this Jun 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment