Closed zotroneneis closed 7 years ago
What's the output of
:python3 import numpy; print(numpy)
?
FWIW: the example should be numpy.
and not np.
in the 2nd line?!
I am seeing -- Omni completion (^O^N^P) Pattern not found
with np.
- and not the =jedi#complete_opened(0)
before it.
@blueyed : Yes, you're right. Fixed it.
@davidhalter The output is:
Traceback (most recent call last):
File "
@zotroneneis
Then you do not have numpy
installed with the Python you are using in Vim.
You will have to e.g. activate your virtualenv before, use something like pyenv
or Neovim for better Python support in general.
btw: it is still unexpected for the =jedi#complete_opened(0)
to show up..
Can you try the following patch, if it improves this (i.e. makes it more silent)?
diff --git i/after/ftplugin/python/jedi.vim w/after/ftplugin/python/jedi.vim
index 2798207..12d7319 100644
--- i/after/ftplugin/python/jedi.vim
+++ w/after/ftplugin/python/jedi.vim
@@ -15,9 +15,9 @@ if g:jedi#auto_initialization
smap <buffer> <Nul> <C-Space>
endif
if len(g:jedi#completions_command)
- execute 'inoremap <expr> <buffer> '.g:jedi#completions_command.' jedi#complete_string(0)'
+ execute 'inoremap <silent> <expr> <buffer> '.g:jedi#completions_command.' jedi#complete_string(0)'
" A separate mapping for select mode: deletes and completes.
- execute 'snoremap <expr> <buffer> '.g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
+ execute 'snoremap <silent> <expr> <buffer> '.g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
endif
endif
endif
@blueyed: The patch did not change the behavior.
Numpy should actually be installed with the python I am using, as conda info --envs
yields
root * /home/myname/anaconda3
and conda list | grep numpy
returns
numpy 1.11.3 py35_0
numpydoc 0.6.0 <pip>
numpydoc 0.6.0 py35_0
Also I can run the following code:
import numpy as np
print('I like jedi')
with :w !python
and :w !python3
without any error.
Do I really need pyenv or Neovim to make it run, when I just want to use the root anaconda python version?
It looks like your Vim installation is not using the same python3
as used in the $PATH?!
Try :!python3 -c "import sys; import numpy; print(sys.modules['numpy'])"
.
And :!which python3
.
Your Vim / jedi-vim Python seems to be /usr/lib/python3.5/, but maybe/probably conda is somewhere else?!
Do I really need pyenv or Neovim to make it run, when I just want to use the root anaconda python version?
No, but I have no experience with setting up conda for Vim, but now that Neovim makes it more flexible.
@blueyed Thanks for your help. I ended up installing neovim and now everything works out fine out of the box!
@blueyed Nice explanation mate. Thanks for sharing this solution, I had the same problem.
Virtualenv support should now also be much better in VIM.
It looks like your Vim installation is not using the same
python3
as used in the $PATH?!Try
:!python3 -c "import sys; import numpy; print(sys.modules['numpy'])"
. And:!which python3
.Your Vim / jedi-vim Python seems to be /usr/lib/python3.5/, but maybe/probably conda is somewhere else?!
Do I really need pyenv or Neovim to make it run, when I just want to use the root anaconda python version?
No, but I have no experience with setting up conda for Vim, but now that Neovim makes it more flexible.
Hello, sorry for bumping. I have a somewhat similar issue: running "echo(g:jedi#environment_path)" in vim returns "auto" running ":!which python3" returns "/c/Users/myusername/AppData/Local/Microsoft/WindowsApps/python3" while "!python3 -c "import sys; import numpy; print(sys.modules['numpy'])" " returns "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. shell returned 9009"
How should I proceed? I'm trying to get the basics of jedi-vim for autocompletion and info on definitions/functions on the main python installation (later I'm gonna try using my different virtual environments, so a way to easily pick an environment and tell jedi-vim to look there would be ideal [i guess variable g:jedi#environment_path would be used for that]).
Thanks a lot.
The problem is that VIM does not even have access to Python, so it's an issue with your VIM or Python installation.
Thanks for the quick response.
I've found out that commands without a '3' (:!python -c "import sys; import numpy; print(sys.modules['numpy'])) returns the expected result. I'm almost sure that vim can access my python installation since I can normally execute a .py file by :!python % inside vim.
I've tried let g:jedi#environment_path = 'C:\Users\myusername\AppData\Local\Programs\Python\Python39\python' but when opening a .py file and trying to write np.ones using the plugin (i type np. and then press ctrl-space to get the suggestion) I get only "jedi#complete_opened(0)". What seems interesting to me is that after explicitly defining g:jedi#environment_path i'm no longer to get the window showing suggestion for command "print" or "property" which I could get before changing the path.
Issue
The completion works fine for python standard library modules. But when I, for instance, try:
I get the following error message:
Jedi-vim debug information
Using Python version: 3
3.5.2 (default, Nov 17 2016, 17:05:23), [GCC 5.4.0 20160609]
/usr/lib/python3.5/site.py
Jedi path:/home/myname/.vim/bundle/jedi-vim/jedi/jedi/__init__.py
/home/myname/.vim/bundle/jedi-vim
/usr/lib/python35.zip
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/usr/lib/python3.5/lib-dynload
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages
_vim_path_
Settings
:version
:messages
:scriptnames
``` 1: ~/.vimrc 2: /usr/share/vim/vim74/ftoff.vim 3: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim 4: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim 5: /usr/share/vim/vim74/filetype.vim 6: ~/.vim/bundle/ultisnips/ftdetect/snippets.vim 7: /usr/share/vim/vim74/ftplugin.vim 8: /usr/share/vim/vim74/indent.vim 9: ~/.vim/bundle/gruvbox/colors/gruvbox.vim 10: /usr/share/vim/vim80/syntax/syntax.vim 11: /usr/share/vim/vim74/syntax/synload.vim 12: /usr/share/vim/vim74/syntax/syncolor.vim 13: ~/.vim/bundle/vim-surround/plugin/surround.vim 14: ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim 15: ~/.vim/bundle/vim-commentary/plugin/commentary.vim 16: ~/.vim/bundle/vim-unimpaired/plugin/unimpaired.vim 17: ~/.vim/bundle/vim-rsi/plugin/rsi.vim 18: ~/.vim/bundle/vim-abolish/plugin/abolish.vim 19: ~/.vim/bundle/jedi-vim/plugin/jedi.vim 20: ~/.vim/bundle/codi.vim/plugin/codi.vim 21: ~/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim 22: ~/.vim/bundle/syntastic/plugin/syntastic/balloons.vim 23: ~/.vim/bundle/syntastic/plugin/syntastic/checker.vim 24: ~/.vim/bundle/syntastic/plugin/syntastic/cursor.vim 25: ~/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim 26: ~/.vim/bundle/syntastic/plugin/syntastic/loclist.vim 27: ~/.vim/bundle/syntastic/plugin/syntastic/modemap.vim 28: ~/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim 29: ~/.vim/bundle/syntastic/plugin/syntastic/registry.vim 30: ~/.vim/bundle/syntastic/plugin/syntastic/signs.vim 31: ~/.vim/bundle/syntastic/plugin/syntastic.vim 32: ~/.vim/bundle/syntastic/autoload/syntastic/util.vim 33: ~/.vim/bundle/ultisnips/plugin/UltiSnips.vim 34: ~/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim 35: ~/.vim/bundle/supertab/plugin/supertab.vim 36: ~/.vim/bundle/vim-snippets/plugin/vimsnippets.vim 37: ~/.vim/bundle/targets.vim/plugin/targets.vim 38: ~/.vim/bundle/editorconfig-vim/plugin/editorconfig.vim 39: ~/.vim/bundle/vim-easy-align/plugin/easy_align.vim 40: ~/.vim/bundle/vim-online-thesaurus/plugin/online-thesaurus.vim 41: ~/.vim/bundle/vim-tmux-navigator/plugin/tmux_navigator.vim 42: ~/.vim/bundle/vimux/plugin/vimux.vim 43: ~/.vim/bundle/ack.vim/plugin/ack.vim 44: ~/.vim/bundle/tagbar/plugin/tagbar.vim 45: ~/.vim/bundle/vim-visual-star-search/plugin/visual-star-search.vim 46: ~/.vim/bundle/vim-airline/plugin/airline.vim 47: ~/.vim/bundle/vim-airline/autoload/airline.vim 48: ~/.vim/bundle/vim-airline/autoload/airline/init.vim 49: ~/.vim/bundle/vim-airline/autoload/airline/parts.vim 50: /usr/share/vim/vim74/plugin/getscriptPlugin.vim 51: /usr/share/vim/vim74/plugin/gzip.vim 52: /usr/share/vim/vim74/plugin/logiPat.vim 53: /usr/share/vim/vim74/plugin/matchparen.vim 54: /usr/share/vim/vim74/plugin/netrwPlugin.vim 55: /usr/share/vim/vim74/plugin/rrhelper.vim 56: /usr/share/vim/vim74/plugin/spellfile.vim 57: /usr/share/vim/vim74/plugin/tarPlugin.vim 58: /usr/share/vim/vim74/plugin/tohtml.vim 59: /usr/share/vim/vim74/plugin/vimballPlugin.vim 60: /usr/share/vim/vim74/plugin/zipPlugin.vim 61: ~/.vim/bundle/ultisnips/after/plugin/UltiSnips_after.vim 62: ~/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim 63: ~/.vim/bundle/jedi-vim/autoload/jedi.vim 64: /usr/share/vim/vim74/ftplugin/python.vim 65: ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim 66: /usr/share/vim/vim74/indent/python.vim 67: /usr/share/vim/vim74/syntax/python.vim 68: ~/.vim/bundle/jedi-vim/after/syntax/python.vim 69: ~/.vim/bundle/vim-airline/autoload/airline/extensions.vim 70: ~/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim 71: ~/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim 72: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tagbar.vim 73: ~/.vim/bundle/vim-airline/autoload/airline/extensions/branch.vim 74: ~/.vim/bundle/vim-airline/autoload/airline/extensions/syntastic.vim 75: ~/.vim/bundle/vim-airline/autoload/airline/extensions/whitespace.vim 76: ~/.vim/bundle/vim-airline/autoload/airline/extensions/po.vim 77: ~/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim 78: ~/.vim/bundle/vim-airline/autoload/airline/section.vim 79: ~/.vim/bundle/vim-airline/autoload/airline/highlighter.vim 80: ~/.vim/bundle/gruvbox/autoload/airline/themes/gruvbox.vim 81: ~/.vim/bundle/vim-airline/autoload/airline/themes.vim 82: ~/.vim/bundle/vim-airline/autoload/airline/util.vim 83: ~/.vim/bundle/vim-airline/autoload/airline/builder.vim 84: ~/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim 85: ~/.vim/bundle/editorconfig-vim/autoload/editorconfig.vim 86: ~/.vim/bundle/syntastic/autoload/syntastic/log.vim 87: ~/.vim/bundle/tagbar/autoload/tagbar.vim 88: ~/.vim/bundle/ultisnips/autoload/UltiSnips.vim ```