pylance-release
pylance-release copied to clipboard
Type of "bpy" is unknown
Environment data
- Language Server version: 2022.7.20
- OS and version: Fedora Linux 36
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.10.5
Code Snippet
import bpy
for area in bpy.context.screen.areas:
print(area)
Repro Steps
- Follow this guide to build Blender as a Python module
- Install it globally
- Import
bpy
in a project
Expected behavior
Able to pick up at least some type information from the module. The module should be installed correctly as it can be imported from the interactive console.
Actual behavior
The type of the whole module is marked as unknown.
Logs
I would try to launch the code to make sure your python environment sees it.
also recommend not installing things globally and to use a virtual environment.
did we set correct python interpreter?
this one?
I have set the interpreter properly I believe.
And yes the code does run fine when I execute it. (Assuming that's what you meant by asking to check whether the environment sees it)
FYI, if I disable the Pylance extension on VSC I also get basic autocomplete.
FYI, BPY is a native Python module. When installing the module it added bpy.so
and a folder named 3.2
to the site-packages
folder located at /usr/lib/python3.10/site-packages/
.
if bpy is a native module, it will need stubs ie. a .pyi file
Closing old issue. As bschnurr mentions, this will need stubs from the python blender authors.