davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.29k stars 370 forks source link

Autocomplete not finding modules in OSX #610

Closed jlintz closed 6 years ago

jlintz commented 8 years ago

Issue

in OSX El Capitan, pip is installing modules to /usr/local/lib/python2.7/site-packages/, my PYTHONPATH contains the following

justin@Justins-MacBook-Pro:~ $ python -c "import sys; print sys.path"
['', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/justin/Library/Python/2.7/lib/python/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/gtk-2.0', '/Library/Python/2.7/site-packages']

but autocomplete is not able to work on any modules inside this directory, but works fine for modules installed in /Library/Python/2.7/site-packages. Unsure why it can't find the modules in that directory

Versions

vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  4 2016 02:34:27)
MacOS X (unix) version
Included patches: 1-1707
Compiled by travis@Traviss-Mac-165.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
+balloon_eval    +folding         +mouse_xterm     +terminfo
+browse          -footer          +multi_byte      +termresponse
++builtin_terms  +fork()          +multi_lang      +textobjects
+byte_offset     +fullscreen      -mzscheme        +timers
+channel         -gettext         +netbeans_intg   +title
+cindent         -hangul_input    +odbeditor       +toolbar
+clientserver    +iconv           +packages        +transparency
+clipboard       +insert_expand   +path_extra      +user_commands
+cmdline_compl   +job             +perl/dyn        +vertsplit
+cmdline_hist    +jumplist        +persistent_undo +virtualedit
+cmdline_info    +keymap          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      +python3/dyn     +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  +lua/dyn         +rightleft       +writebackup
+diff            +menu            +ruby/dyn        -X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     -xsmp
+emacs_tags      +mouseshape      +startuptime     -xterm_clipboard
+eval            +mouse_dec       +statusline      -xterm_save
+ex_extra        -mouse_gpm       -sun_workshop    -xpm
+extra_search    -mouse_jsbterm   +syntax
+farsi           +mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -L/usr/local/lib -L. -L/usr/local/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE
1: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/vimrc
  2: ~/.vimrc
  3: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
  4: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
  5: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
  6: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
  7: ~/dot-vim/autoload/pathogen.vim
  8: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/ftoff.vim
  9: ~/dot-vim/bundle/puppet/ftdetect/puppet.vim
 10: ~/dot-vim/bundle/vim-go/ftdetect/gofiletype.vim
 11: ~/dot-vim/bundle/vim-colors-solarized/colors/solarized.vim
 12: ~/dot-vim/bundle/airline/plugin/airline.vim
 13: ~/dot-vim/bundle/airline/autoload/airline.vim
 14: ~/dot-vim/bundle/airline/autoload/airline/init.vim
 15: ~/dot-vim/bundle/airline/autoload/airline/parts.vim
 16: ~/dot-vim/bundle/comments.vim/plugin/comments.vim
 17: ~/dot-vim/bundle/ctrlp.vim/plugin/ctrlp.vim
 18: ~/dot-vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
 19: ~/dot-vim/bundle/fugitive/plugin/fugitive.vim
 20: ~/dot-vim/bundle/jedi-vim/plugin/jedi.vim
 21: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/ftplugin.vim
 22: ~/dot-vim/bundle/minibufexpl.vim/plugin/minibufexpl.vim
 23: ~/dot-vim/bundle/nerdtree/plugin/NERD_tree.vim
 24: ~/dot-vim/bundle/nerdtree/autoload/nerdtree.vim
 25: ~/dot-vim/bundle/nerdtree/lib/nerdtree/path.vim
 26: ~/dot-vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim
 27: ~/dot-vim/bundle/nerdtree/lib/nerdtree/menu_item.vim
 28: ~/dot-vim/bundle/nerdtree/lib/nerdtree/key_map.vim
 29: ~/dot-vim/bundle/nerdtree/lib/nerdtree/bookmark.vim
 30: ~/dot-vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim
 31: ~/dot-vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim
 32: ~/dot-vim/bundle/nerdtree/lib/nerdtree/opener.vim
 33: ~/dot-vim/bundle/nerdtree/lib/nerdtree/creator.vim
 34: ~/dot-vim/bundle/nerdtree/lib/nerdtree/flag_set.vim
 35: ~/dot-vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim
 36: ~/dot-vim/bundle/nerdtree/lib/nerdtree/ui.vim
 37: ~/dot-vim/bundle/nerdtree/lib/nerdtree/event.vim
 38: ~/dot-vim/bundle/nerdtree/lib/nerdtree/notifier.vim
 39: ~/dot-vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim
 40: ~/dot-vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
 41: ~/dot-vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
 42: ~/dot-vim/bundle/syntastic/plugin/syntastic/autoloclist.vim
 43: ~/dot-vim/bundle/syntastic/plugin/syntastic/balloons.vim
 44: ~/dot-vim/bundle/syntastic/plugin/syntastic/checker.vim
 45: ~/dot-vim/bundle/syntastic/plugin/syntastic/cursor.vim
 46: ~/dot-vim/bundle/syntastic/plugin/syntastic/highlighting.vim
 47: ~/dot-vim/bundle/syntastic/plugin/syntastic/loclist.vim
 48: ~/dot-vim/bundle/syntastic/plugin/syntastic/modemap.vim
 49: ~/dot-vim/bundle/syntastic/plugin/syntastic/notifiers.vim
 50: ~/dot-vim/bundle/syntastic/plugin/syntastic/registry.vim
 51: ~/dot-vim/bundle/syntastic/plugin/syntastic/signs.vim
 52: ~/dot-vim/bundle/syntastic/plugin/syntastic.vim
 53: ~/dot-vim/bundle/syntastic/autoload/syntastic/util.vim
 54: ~/dot-vim/bundle/tabular/plugin/Tabular.vim
 55: ~/dot-vim/bundle/tagbar/plugin/tagbar.vim
 56: ~/dot-vim/bundle/vim-go/plugin/go.vim
 57: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
 58: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
 59: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/logiPat.vim
 60: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
 61: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
 62: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
 63: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
 64: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
 65: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
 66: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
 67: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
 68: ~/dot-vim/bundle/tabular/after/plugin/TabularMaps.vim
 69: ~/dot-vim/bundle/tabular/autoload/tabular.vim
 70: ~/dot-vim/bundle/airline/autoload/airline/extensions.vim
 71: ~/dot-vim/bundle/airline/autoload/airline/extensions/quickfix.vim
 72: ~/dot-vim/bundle/airline/autoload/airline/extensions/netrw.vim
 73: ~/dot-vim/bundle/airline/autoload/airline/extensions/ctrlp.vim
 74: ~/dot-vim/bundle/airline/autoload/airline/extensions/tagbar.vim
 75: ~/dot-vim/bundle/airline/autoload/airline/extensions/branch.vim
 76: ~/dot-vim/bundle/airline/autoload/airline/extensions/syntastic.vim
 77: ~/dot-vim/bundle/airline/autoload/airline/extensions/whitespace.vim
 78: ~/dot-vim/bundle/airline/autoload/airline/extensions/wordcount.vim
 79: ~/dot-vim/bundle/airline/autoload/airline/section.vim
 80: ~/dot-vim/bundle/airline/autoload/airline/highlighter.vim
 81: ~/dot-vim/bundle/airline/autoload/airline/themes/dark.vim
 82: ~/dot-vim/bundle/airline/autoload/airline/themes.vim
 83: ~/dot-vim/bundle/airline/autoload/airline/util.vim
 84: ~/dot-vim/bundle/airline/autoload/airline/builder.vim
 85: ~/dot-vim/bundle/airline/autoload/airline/extensions/default.vim
 86: ~/dot-vim/bundle/syntastic/autoload/syntastic/log.vim
 87: ~/dot-vim/bundle/tagbar/autoload/tagbar.vim
 88: ~/dot-vim/bundle/ctrlp.vim/autoload/ctrlp.vim
 89: ~/dot-vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
 90: ~/dot-vim/bundle/ctrlp-py-matcher/autoload/pymatcher.vim
 91: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/syntax/python.vim
 92: ~/dot-vim/bundle/jedi-vim/after/syntax/python.vim
 93: ~/dot-vim/bundle/jedi-vim/autoload/jedi.vim
 94: ~/dot-vim/bundle/flake8/ftplugin/python_flake8.vim
 95: ~/dot-vim/bundle/jedi-vim/ftplugin/python/jedi.vim
 96: /opt/homebrew-cask/Caskroom/macvim/7.4.101/MacVim.app/Contents/Resources/vim/runtime/ftplugin/python.vim
 97: ~/dot-vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim
 98: ~/dot-vim/bundle/syntastic/syntax_checkers/python/flake8.vim
 99: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pyflakes.vim
100: ~/dot-vim/bundle/syntastic/syntax_checkers/python/frosted.vim
101: ~/dot-vim/bundle/syntastic/syntax_checkers/python/mypy.vim
102: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pep257.vim
103: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pep8.vim
104: ~/dot-vim/bundle/syntastic/syntax_checkers/python/prospector.vim
105: ~/dot-vim/bundle/syntastic/syntax_checkers/python/py3kwarn.vim
106: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pycodestyle.vim
107: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pydocstyle.vim
108: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pylama.vim
109: ~/dot-vim/bundle/syntastic/syntax_checkers/python/pylint.vim
110: ~/dot-vim/bundle/syntastic/syntax_checkers/python/python.vim
davidhalter commented 8 years ago

:python print(sys.path)?

davidhalter commented 8 years ago

Feel free to crawl through our isue tracker. there's a lot of people with issues on OSX.

johnzeng commented 8 years ago

Did you 'pip install jedi' before you use the plugin?

jlintz commented 8 years ago

@davidhalter ah looks like the path is wrong in VIM but correct from the cmdline, any idea how I can modify the path that it's using inside VIM? Thanks

davidhalter commented 8 years ago

I have no idea. Some VIM versions on MacOS seem to be broken.

aliev commented 8 years ago

@jlintz

I'm using this small script to detect system site-packages, virtualenv and modules inside current directory (using this script instead vim-virtualenv):

if has('python')
py << EOF
import os
import os.path, sys
import vim

if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    execfile(activate_this, dict(__file__=activate_this))
    python_version = os.listdir(project_base_dir + '/lib')[0]

    site_packages = os.path.join(project_base_dir, 'lib', python_version, 'site-packages')
    current_directory = os.getcwd()

    sys.path.insert(1, site_packages)
    sys.path.insert(1, current_directory)
EOF
endif

(It works fine for me).

Example for activated virtualenv:

(:python import sys; print sys.path)

['/Users/aliev/Projects/dede/.env/lib/python2.7/site-packages', '/Users/aliev/Projects/dede', '/Users/aliev/Projects/dede/.env/lib/python2.7/site-packages', '/Users/aliev/Project
s/dede/.env', '/Users/aliev/Projects/sentry/src', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/pyt
hon2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Fram
eworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Py
thon.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/
2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages', '_vim_path_']

Also try to install vim from the sources.

rogeriofonseca commented 8 years ago

@aliev Where should I'll be created this script? Within the .vimrc or is a shell script?

aliev commented 7 years ago

@rogeriofonseca just add it inside vimrc

davidhalter commented 6 years ago

Ok. Now that virtualenv support is part of Jedi itself (and we merged it in jedi-vim), I feel like this is not an issue anymore. Please open a new issue if you are still having this (we have updated a lot of our debug scripts to help us with understanding your issues).