8

I have installed several libraries into a conda environment named "foo". I am using Visual Studio Code as my IDE.

Autocomplete works fine for almost all packages, except for the library "openmesh" (see below): Autocomplete with openmesh

Autcomplete with a different library

I have selected the correct python interpreter in VS Code: Interpreter

As confirmed in the bottom left corner.

Version

Furthermore, I have tried to add it to the autocomplete path in the settings of VS Code, however, there was no change, even after relaunching.

Extra Paths

Autocomplete works fine with PyCharm, as seen here: Pycharm

What am I doing wrong?

tlk13
  • 113
  • 5
  • Ctrl+Click on the `openmesh`, can you get into the module? `openmesh` has not been colored, it's a little weird. – Steven-MSFT Jan 19 '22 at 07:22
  • When you run `~/miniconda3/envs/foo/bin/pip list` in a terminal, does it contain `openmesh`? When you open a terminal in VS code, does the prompt show your venv prefix? – carlfriedrich Jan 19 '22 at 08:55
  • @Steven-MSFT I cannot go to Declaration, Definition or Type Definition. It always says "Declaration not found for 'om'". – tlk13 Jan 19 '22 at 10:07
  • @carlfriedrich it does it contain `openmesh`. In VS code, the prompt shows me the venv prefix `(foo)`, i.e. the Python Interpreter I selected. – tlk13 Jan 19 '22 at 10:11
  • 1
    @tlk13, were you able to figure out a solution to this? I'm facing a similar issue with AWS CDK library. I've tried re-installing VSCode with no avail. – m01010011 Jul 05 '23 at 02:22
  • Hi @m01010011, very cool that you found my initial issue after all this time! Unfortunately i was not able to solve it. basically i just switched back and forth between documentation and VS Code until i had it memorised :(. if you find a solution, do let me know! – tlk13 Jul 11 '23 at 12:36

3 Answers3

0

Had a similar problem, auto-completion was not working with python.

The following worked for me:

Use the keyboard shortcut to open the command palette:

Ctrl + Shift + P

and search for:

Python: Restart Language Server

Hit enter. Now give it another try.

0

https://code.visualstudio.com/docs/python/environments : There are two types of environments that you can create for your workspace: virtual and conda environments.

you have to work into a workspace

Daniel L
  • 1
  • 1
0

Open your Terminal, activate your environment (i.e. conda activate foo), and then launch VS Code from within terminal in which you activated your environment (i.e. code . or code /path/to/directory). This worked for me.

If you are on Windows you can follow this link