VS Code autocomplete for ArcPy
What I had to do to get IntelliSense working with my arcpy project in VS Code:
In my project folder I created a new folder called
.vscode
In this folder I created a file called
settings.json
, and added the following to the json file:{ "python.pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\python.exe" }
This is the path to my arcpy python install location - if yours is in a different location then specify that path instead.
Now when I open that project folder, I can type
arcpy.
and then press Ctrl+Space two or three times and it'll pop up a message "Loading"I had to wait several seconds (it wasn't a quick load), then the IntelliSense works.
I did find I had to do the Ctrl+Space step and wait for the load every time I opened the project, but while it was open the IntelliSense works fine after initial load
With the help of Midavalo answer, I figured out how to set up autocomplete for my VS Code. In VS Code just go under File -> Preferences -> Settings and then within Settings go for Text Editor -> Suggestions -> Quick Suggestions and open settings.json(Edit in settings.json). Over there add the same line of code that Midavalo posted
{
"python.pythonPath": 'Path to your envrionment'
}
However, I think that my approach will set every python project environment to the one you pointed but there should be no problem to override this change on the 'select interpreter' option.