I would like to get suggestions/autocomplete as I am typing methods and functions in VS Code for arcpy. Currently, IntelliSense would suggest only functions or methods that I have been using within the file, but would not some that I haven't.

I am using Python and Kite extensions. I have also cloned the Python environment in Pro and I am using that as a Python environment in VS Code.

I have tried to play a little bit with editor.quickSuggestions but haven't really done much.

  • Does VS Code recognise the correct arcgis python environment? What happens when you press Ctrl+Space after typing arcpy. ? Sometimes I have to type that with ctrl+space a couple times and give it a few seconds before the Intellisense works the first time, but then it's there for the entire session (have to do it again the next session) – Midavalo May 24 at 16:11
  • Thank you for answer Midavalo, I have tried with ctrl+space but I would again get the same suggestions(only the ones that I have used in my code already). What I am looking for is to get suggestions similarly as in Python console within Pro. :( And yes, I think VS Code recognizes the environment, as I have no problem executing the program with Code. – Kumbra May 24 at 16:14
  • Have you created a venv in vs code for arcpy? Having it run could just be because python is in the windows PATH environment. – Midavalo May 24 at 16:24
  • Well, besides selecting an interpreter in VS Code I haven't done something else. So currently I see in the left bottom of Code - Python 3.6.7. 64-bit('arcgis-py3-clone': conda). And the path is pointing to the environment ArcGIS Pro have created. – Kumbra May 24 at 16:34
  • I think that venv was the wrong term in my comment above, but I have done a quick test and added an answer below with what works for me – Midavalo May 24 at 16:57

What I had to do to get IntelliSense working with my arcpy project in VS Code:

  1. In my project folder I created a new folder called .vscode

    enter image description here

  2. 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.

  3. 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"

    enter image description here

    I had to wait several seconds (it wasn't a quick load), then the IntelliSense works.

    enter image description here

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

| improve this answer | |
  • Thank you so much! This exact same approach hasn't worked for me but I have added your line of code with my python environment path under File -> Preferences -> Settings. Then go for Text Editor -> Suggestions -> Quick Suggestions 'Edit in settings.json'. However, I think that my approach will set every project to Python environment but there should be no problem to override this change on the 'select interpreter' option. I just wanted to write in case someone needs my approach. Thank you Midavalo – Kumbra May 24 at 17:07
  • @Kumbra Feel free to edit my answer with the extra steps that made yours work, or add your own answer – Midavalo May 24 at 17:12

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.