Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error when loading source jedi: Failed to start server" when using virtualenv at Windows #170

Closed
thiamteck opened this issue Jun 24, 2018 · 6 comments

Comments

@thiamteck
Copy link

thiamteck commented Jun 24, 2018

Problem summary

Code completion work well on python files without virtualenv, but when virtualenv activated, deoplete hit error on noevim startup as below;

deoplete-jedi-virtualenv

The problem shall be due to the path it pointed to is contains front slash which is interpreted as command option in Windows.

invalid_parameters

Expected

Code completion shall still work with virtualenv

Environment Information

  • OS: Windows 10
  • Neovim version: 0.3.0
  • Python version: 3.6

Provide a minimal init.vim with less than 50 lines (required)

let g:python3_host_prog=expand('$HOME/AppData/Local/nvim/python_env/neovim3/Scripts/python.exe')
let g:python_host_prog=expand('$HOME/AppData/Local/nvim/python_env/neovim/Scripts/python.exe')

call plug#begin('~/AppData/Local/nvim/plugged')
if has('nvim')
    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
    Plug 'Shougo/deoplete.nvim'
    Plug 'roxma/nvim-yarp'
    Plug 'roxma/vim-hug-neovim-rpc'
endif 
Plug 'zchee/deoplete-jedi'

" Use deoplete.
let g:deoplete#enable_at_startup = 1

Steps to reproduce the issue after starting Neovim (required)

  1. at command prompt, activate virtualenv : env\Scripts\activate
  2. open a python file: nvim test.py

Screen shot (if possible)

deoplete-jedi-virtualenv
invalid_parameters

@Shougo
Copy link
Collaborator

Shougo commented Jun 25, 2018

Please test #171.

@thiamteck
Copy link
Author

hi @Shougo , after some testing, I found even the path for python program is different in Windows, and below is the modifications that was tested working (starting line 475):

        if 'VIRTUAL_ENV' in os.environ:
            if os.name == 'nt':
                prog = os.path.join(self.env['VIRTUAL_ENV'], 'Scripts', 'python')
            else:
                prog = os.path.join(self.env['VIRTUAL_ENV'], 'bin', 'python')
        elif python_path:
            prog = python_path
        else:
            prog = 'python'

        self.cmd = [prog, '-u', os.path.normpath(__file__),
                    '--desc-length', str(desc_len)]

Complete file at: https://gist.github.com/thiamteck/9e9a0eac1aa27c021af8f4d395cfd1a9

Thank you.

@blueyed
Copy link
Collaborator

blueyed commented Jun 27, 2018

JFI: upgrading Jedi would help here, too - it has better virtualenv support itself.
#156

For jedi-vim I've started working on commands to dynamically select a specific version.
Jedi has an API to get virtual envs / system envs.
davidhalter/jedi-vim#836

@thiamteck
Copy link
Author

hi @blueyed , I am already using Jedi 0.12.0, will also give jedi-vim a try.

@Shougo Shougo closed this as completed in 0114863 Jun 30, 2018
Shougo added a commit that referenced this issue Jun 30, 2018
@Shougo
Copy link
Collaborator

Shougo commented Jun 30, 2018

@blueyed I know.
But jedi in deoplete-jedi is not updated yet.

So I have merged the changes.

For jedi-vim I've started working on commands to dynamically select a specific version.
Jedi has an API to get virtual envs / system envs.
davidhalter/jedi-vim#836

When starts for deoplete-jedi...

@blueyed
Copy link
Collaborator

blueyed commented Jul 1, 2018

@thiamteck
Out of curiosity: __file__ on Windows might contain mixed slashes?
(Only the rplugin/python/deoplete part has them.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants