coc-pyright: could not be resolved if use pyenv local

I use pyenv for manage virtualenv of python, but if use pyenv local(.python-version file in local dir) in coc-pyright, raise reportMissingImports error on import something. image

pyenv shell is working. PYENV_VERSION environment variable can be accepted.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 18 (7 by maintainers)

Most upvoted comments

I’ll test pyenv/pipenv later, trying to make it works with Pyright.

coc-pyright v1.1.106 adds support for pyenv local, please give it a try.

@rid-32

Is the “workspace folder” resolved with the correct directory name?

Try to do :echo WorkspaceFolders or CocCommand workspace.workspaceFolders

Does the output show the name of the directory where pyrightconfig.json is located?

If nothing is displayed or the correct directory is not displayed, you may want to put the following settings in .vimrc or init.vim.

au FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json', 'env']

Ref: Resolve workspace folder https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders

@yaegassy pyrightconfig.json is working, but is not optimal, everyone project maybe place a file. In addition, python.venvPath is not suitable for pyenv