I am new to using vscode with python.exe for arcgispro. My interpreter is set to the arcgispro-py3-env\python.exe.
I would like to be able to run python code within vscode but I am running into some issues with pylance, which does not seem to recognize arcgis functions or able to set my working directory.
For example when I try to set my working directory to
env.workspace = wd
I get the following error:
Cannot assign member "workspace" for type "GPEnvironment"
Pylance(reportGeneralTypeIssues) Member "workspace" is unknown
Or when I try to execute the following
code arcpy.management.Project, I get the following error:
"management" is not a known member of module "arcpy"
Pylance(reportGeneralTypeIssues)
I don't want to use the #type:ignore fix as this will be cumbersome with lots of code.
Easiest way to avoid a Pylance error is to add
import arcpy.management:The reason is most likely that
arcpy.managementis unkonwn toarcpy/__ini__.py.As for
arcpy.env.workspace, looking at the auto-completion,arcpy.envseems to be some sort of dictionary class:With this knowledge, you could use the
[]operator to avoid a Pylance error. For example: