ncm2 / ncm2-jedi

MIT License
23 stars 11 forks source link

Completions not working in virtual environment created with pyenv and venv #23

Closed bo5o closed 5 years ago

bo5o commented 5 years ago

Issue

Completions are not working for packages I installed in a virtual environment that was created with a python installation managed by pyenv.

Steps to reproduce

Expected behavior

I can see the packages of my virtual environment in the completions list. I can also complete modules, methods etc. from installed packages.

Completions work fine with plain jedi-vim (no ncm2).

Actual behavior

I can not see completions of packages of the activated environment. Instead I can only see completions of my system python, which is a different version and not even the python executable I used when creating the virtual environment.

Minimal vimrc

call plug#begin('~/.local/share/nvim/plugged')
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-jedi'
Plug 'davidhalter/jedi-vim'
call plug#end()

set nocompatible

let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'

syntax on
filetype plugin indent on

autocmd BufEnter * call ncm2#enable_for_buffer()

set completeopt=noinsert,menuone,noselect

Output of “:verbose JediDebugInfo”

#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: 0.10.0-3-g4f2499e
 - jedi git submodule status:  005f69390c4b1a3b864e7373cfcbdaf95e65411d pythonx/jedi (v0.15.1)
 - parso git submodule status:  c0ace63a6905500e18d8ac06af1a0a9057e63498 pythonx/parso (v0.5.1)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.6.8 (default, Aug 20 2019, 17:12:48), [GCC 8.3.0]`
 - global site module: `/usr/lib/python3.6/site.py`

##### Jedi

 - path: `~/.local/share/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.15.1

##### Jedi environment: <Environment: 3.7.4 in /tmp/myapp/.venv>

 - executable: /tmp/myapp/.venv/bin/python
 - sys_path:
    - `~/.pyenv/versions/3.7.4/lib/python37.zip`
    - `~/.pyenv/versions/3.7.4/lib/python3.7`
    - `~/.pyenv/versions/3.7.4/lib/python3.7/lib-dynload`
    - `/tmp/myapp/.venv/lib/python3.7/site-packages`

##### Known environments

 - <Environment: 3.7.4 in /tmp/myapp/.venv> (/tmp/myapp/.venv/bin/python)
 - <Environment: 3.7.4 in ~/.pyenv/versions/3.7.4> (~/.pyenv/versions/3.7.4/bin/python3.7)
 - <Environment: 3.6.8 in /usr> (/usr/bin/python3.6)
 - <Environment: 2.7.15 in /usr> (/usr/bin/python2.7)

##### Settings

g:jedi#completions_enabled = 0 (default: 1)

  omnifunc=python3complete#Complete
        Zuletzt gesetzt in /tmp/.mount_nvimt3iaAF/usr/share/nvim/runtime/ftplugin/python.vim line 41
  completeopt=noinsert,menuone,noselect
        Zuletzt gesetzt in ~/dotfiles/nvim/.config/nvim/init.vim line 178

#### :version

NVIM v0.4.0-2014-g554566cce
Build type: RelWithDebInfo
LuaJIT 2.0.5
Features: +acl +iconv +tui

Output of :checkhealth provider

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: ~/.pyenv
  - INFO: Using: g:python_host_prog = "/usr/bin/python2"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /usr/bin/python2
  - INFO: Python version: 2.7.15
  - INFO: pynvim version: 0.3.2

## Python 3 provider (optional)
  - INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: ~/.pyenv
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.6.8
  - INFO: pynvim version: 0.3.2
bo5o commented 5 years ago

I was able to fix the issue.

Although in the above debug info the jedi version is up-to-date (v0.15.1), there was another jedi installation in my system python (/usr/bin/python3), which was outdated (v0.12). I don't know why, but when I updated this version, everything just worked.