Skip to content

Completions not working for modules installed within a pipenv virtual environment? #390

Closed

Description

@mjlbach

I use pipenv to manage my python virtual environments/projects. I've noticed that when I create and install pyls within a pipenv virtual environment, only standard modules (os, sys, etc.) have completions. External modules like numpy, requests, etc. do not show completions. The only combination that currently gives me external module completion is when I've installed pyls within an activated virtualenv created via the built-in venv module which also contains the external modules.

Activity

  1. rebelot commented on Jul 11, 2018

    @rebelot

    Any news on this? I experience the same issue. I have created a virtualenv which has access to systems modules and Jedi is properly listing modules that are non directly installed in the venv, nonetheless pyls only lists standard modules. It is like pyls is explicitly passing a syspath to Jedi which is inconsistent with Jedi’s ways of detecting it

  2. rebelot commented on Jul 12, 2018

    @rebelot

    FYI I use neovim, and specifying pyls as python -m pyls solved the issue for me

  3. mjlbach commented on Jul 12, 2018

    @mjlbach
    Author

    @tommasolaurenzi This solution did not work for me with pipenv. Thanks for the suggestion though. I believe the issue may be upstream with how Jedi reads sys.path

  4. justinmoon commented on Aug 2, 2018

    @justinmoon

    I'm having same problem.

    Neither autocomplete nor go-to-definition work for me using vim with the ALE plugin when using a pipenv environment. Problem could be with ALE but figured I should chime in here.

    Linting works fine. Autocomplete and go-to-definition work for standard library.

    edit:

    Seems Jedi is also used for go-to-definition. So @mjlbach's theory makes some sense in my case.

  5. tacho commented on Aug 31, 2018

    @tacho

    I was having the same problem, but only under macOS, Linux was fine, so this got me digging. Fixed in davidhalter/jedi#1212.

  6. esn89 commented on Feb 13, 2019

    @esn89

    @rebelot

    How did you manage to set this? Is this in LanguageClient-neovim?

  7. nicksspirit commented on Jun 21, 2019

    @nicksspirit

    What I did to get pyls to get me proper code completions was to install pyls in my virtual environment and then use an executable script to start the pyls server with the virtual environment activated.
    I am using sublime text as my editor and then fish as my terminal shell. I then wrote this fish script (easily can be rewritten in bash)

    #!/usr/bin/env fish
    
    echo "["(date)"] "(pwd) >> ~/Developer/pyls.log
    
    set CWD (pwd)
    
    if test -n "$VIRTUAL_ENV"
        source "$VIRTUAL_ENV"/bin/activate.fish
        "$VIRTUAL_ENV"/bin/pyls
    
    else if test -d "$CWD/.venv"
        source "$CWD"/.venv/bin/activate.fish
        "$CWD"/.venv/bin/pyls
    
    else
        exit
    end

    Then in sublime text I set the command to start the pyls server to be the script in sublime text's LSP settings.

    "pyls":
    		{
    			"enabled": true,
    			"command":["/path/to/script/pyls.fish"],
    			"syntaxes":
    			[
    				"Packages/Python/Python.sublime-syntax",
    				"Packages/MagicPython/grammars/MagicPython.tmLanguage"
    			]
    		},
  8. sinkerine commented on Mar 29, 2020

    @sinkerine

    #657 supports passing your own syspath. I use Emacs and manage to pass my pyenv syspath to pyls in emacs-lsp/lsp-mode#1393

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions