question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't seem to resolve reportMissingImports with coc-pyright on my python3.9 venv on neovim

See original GitHub issue

Hi, I recently switched to neovim from vim yesterday and installed coc-pyright with it since coc-python’s README recommended it, I have a python3.9 venv at /opt/, I have extensively searched through issues here and found #87 similar to my issue. I have even installed pynvim in my venv with python -m pip install pynvim and added this line in my neovim init.vim:

let g:python3_host_prog = '/opt/bin/python'

Here is my output of CocInfo:

## versions
    
vim version: NVIM v0.4.3   
node version: v15.5.0
coc.nvim version: 0.0.80-cf0e8400a4
coc.nvim directory: /home/ubuntu/.config/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux 
        
## Log of coc.nvim

2021-01-01T06:53:11.766 INFO (pid:4799) [services] - registered service "eslint"
2021-01-01T06:53:11.841 INFO (pid:4799) [services] - registered service "pyright"
2021-01-01T06:59:31.454 INFO (pid:4907) [services] - Pyright Server state change: stopped => starting
2021-01-01T06:53:11.926 INFO (pid:4799) [plugin] - coc.nvim 0.0.80-cf0e8400a4 initialized with node: v15.5.0 after 316ms
2021-01-01T06:53:11.945 INFO (pid:4799) [language-client-index] - pyright started with 4920
2021-01-01T06:53:12.251 INFO (pid:4799) [services] - Pyright language server state change: starting => running
2021-01-01T06:53:12.260 INFO (pid:4799) [services] - service pyright started
2021-01-01T06:53:15.585 INFO (pid:4799) [attach] - receive notification: showInfo []

I have added pyrightconfig.json on my venv root folder at /opt/:

{
    "include": [
        "**/site-packages",
        "**/cogs",
        "**/core"
    ],

    "exclude": [
        "**/__pycache__"
    ],

    "executionEnvironments": [
        {
            "root": "lib/python3.9/site-packages",
            "pythonVersion": "3.9",
            "pythonPlatform": "Linux"
        }
    ],

    "venvPath": "/opt",
    "reportMissingImports": true,
    "pythonVersion": "3.9",
    "pythonPlatform": "Linux"
}

and here is my coc-settings.json stored at ~/.config/nvim/:

{
    "python.pythonPath": "/usr/bin/python3.9",
    "python.venvPath": "/opt/"
}

even with these settings, whenever I open any *.py file, I get pyright showing warning about missing imports althought those packages are already present in my venv site-packages: /opt/lib/python3.9/site-packages

Is there anything I did wrong or I missed in these settings? I apologise for any inconvenience I’m still new with pyright, if someone can help me out I would be really grateful. 🙏🏼

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
yaegassycommented, Jan 28, 2021

@felippemr There is no setInterpreter command in coc-pyright.

It is recommended that you activate the virtual environment, then go to the project root and launch Vim/Neovim.

If you still cannot import correctly, place pyrightconfig.json in the project root and settting venvPath and venv appropriately.


Example: pyrightconfig.json

If the location of your virtual environment is /path/to/projectroot/.venv.

{
  "venvPath": "/path/to/projectroot"
  "venv": ".venv"
}
2reactions
fannheywardcommented, Jan 29, 2021

I’m going to close this issue, open a new issue if you still has this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vim plugin - Pyright, report missing imports error in neovim
I'm getting this error, which doesn't make sense because the libraries are installed, and the correct python interpreter path is selected.
Read more >
reportmissingimports - You.com | The Search Engine ...
How do I resolve reportMissingImports problem when importing flask? ... Select your newly created python interpreter inside your venv. add "python.terminal.
Read more >
Installing and using virtualenv with Python 3
To create a new virtual environment using your custom installed version of Python, follow these steps: The following steps use Python version ...
Read more >
neoclide/coc.nvim - Gitter
my venv name is panda, should python.venvPath point to it, or to its parent dir? Heyward ...
Read more >
Resolve issues between Python and Linux with virtualenv
Ubuntu, Debian and other versions of Linux still ship with Python 2 installed, despite Python 3's decade on the scene. Python 3 debuted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found