简体   繁体   中英

vscode python intellisense doesn't work PROPERLY for some modules

the title explain's the problem, the module is tensorflow, recently i had the same issue with numpy also, but adding my site-packages path to vscode python->autoComplete->extraPaths fixed the problem in case of numpy, but it doesn't work for tensorflow

now let me tell you what i mean by PROPERLY: when i write a dot(.) after module name and then press CTRL + SPACE it shows nothing to me but when i type the first letter it starts showing attributes.

CTRL + SPACE after dot

after typing the first letter

it's not such a big deal but i just feel want it fixed, and i want to know the reason behind it to prevent such things again.

also my extraPaths in setting.json:

{"python.autoComplete.extraPaths": [
        "/home/shayan/.local/lib/python3.10/site-packages/keras",
        "/home/shayan/.local/lib/python3.10/site-packages/tensorflow/",
        "/lib/python3.10/site-packages/keras",
        "/home/shayan/.local/lib/python3.10/site-packages/keras",
        "/usr/lib/python3.10/site-packages",
        "/home/shayan/.local/lib/python3.10/site-packages",
        "/home/shayan/.local/lib/python3.10/site-packages/numpy",
        "/usr/lib/python3.10/site-packages/tensorflow",
        "/home/shayan/.local/lib/python3.10/site-packages/tensorflow",
    ]
}

The reason for all this is probably because you have multiple python versions on your machine, which messes up the vscode environment.

It is recommended that you use a virtual environment, which is very helpful for using different python versions and installing different packages in different environments.

How to create and use a virtual environment:

Create a virtual environment named .venv using the following command in the vscode terminal

python -m venv .venv

Activate the virtual environment with the following command

.venv\scripts\activate

PS: Select the python interpreter in the virtual environment, and then create a new terminal, the virtual environment will be automatically activated.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM