'Pylance does not recognise newly installed pip packages

I am getting the following error while trying to import newly installed packages from pip:

Import "<package>" could not be resolved Pylance(reportMissingImports)

After I restart VS code, Pylance seems to then be able to recognise the package.

Is there any fix to this as it is very annoying!



Solution 1:[1]

This question will happen when Pylance doesn't detect the module immediately. You may Reload Window from Command Palette to refresh the current project.

Solution 2:[2]

If you are using VS Code, open the command pallet and run "Python: Restart Language Server"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Molly Wang-MSFT
Solution 2 William Riddle