I'm attempting to configure VS Code for ArcPy/ArcGIS Pro development, and things have been going ok so far, however I have run into an issue I am not sure how to resolve. I'm also curious to hear how other in the community have configured VS Code - I want to make sure I'm not way off base. Here is how I have configured VS Code:
I first cloned a Python environment from the ArcGIS Pro Package Manager, and then set the location of the Python interpreter in VS Code to the "python.exe" in my cloned env (which for me, was in this folder: %LocalAppData%\ESRI\conda\envs\my-cloned-environment\python.exe).
And that was actually all I needed to do in order to run and debug a script. I am able to create a new Python debugging configuration in VS Code, set breakpoints step through the code, and get IntelliSense on all ArcPy modules & methods. However, there is still something I am not fully understanding, I think..
On VS Code Terminal launch, I get the following error:
That looks to me like the system PATH environment variable has not been configured for Conda, and Powershell does not recognize the conda command. The Conda docs actually recommend not modifying the PATH env var, but if I do, I can resolve the error above, and the conda command is recognized.
However, that yields another error, "CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’.”
Looking at the error message, I see that it is saying to run command conda init powershell, however, this also yields an error an I am stuck at this point, unsure how to proceed. Running VS Code as admin did not resolve the issue.
To further compound my confusion, I came across this in the Esri docs saying "propy.bat" or "proenv.bat" should be used, but I don't know how I would integrate with VS Code:
https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/using-conda-with-arcgis-pro.htm
I'm curious to hear how other VS Code users have their local development environment configured, if you ran into any of these issues, how you resolved them, etc. Or am I just completely way off base in my methods and attempts to get VS Code configured lol??
Solved! Go to Solution.
If the accepted solution didn't help, could it be the version of Conda isn't compatible with VSCode? My version of VSCode (1.78.2) seems to require Conda 4.4+. I have ArcPro 3.1 and it came with Conda 4.14, which isn't working with the accepted solution.
I am running VSCode 1.82.0 and it says it wants conda > 4.4 too, and it works fine with 4.14 and also with the current Miniconda3 version. I am on Windows 11. What is it doing wrong for you?
It can't seem to activate conda. It does run the script otherwise, though *shrug.
Last Friday I tried switching again to use ONLY the Esri install of conda and friends but it's just not worth it. I switched back over to use Miniconda in VScode (and at the command line) again.
It whined and made me run "conda init" again but I did and now I am back working from both VSCODE and command line. I think the "conda init" requirement is awful but at least this time it almost worked for me. (It edits my startup files but not the right ones. I still have to copy its changes into my .bashrc file.)
I installed Miniconda to C:/Users/bwilson/Miniconda3, and added CONDA_PATH="C:\Users\bwilson\Miniconda3\Scripts" to my environment, launched a new shell, then did "conda activate arcgis_tools" and indeed it gave me the CommandNotFound error. Then I ran "conda init bash" and then copied the gunk it added to my .bash_profile to the .bashrc that I use
Super easy ha ha ha kidding. Stupidly complex.
I tired everything in this post a few times and I am stuck also. This was not an issue in Pro 2.9 but 3.13 I got today and keep getting the message.
Also getting this message \profile.ps1 is not digitally signed in red. Maybe since I do not have admin rights.
For the person that posted to edit setting.json which one and where?
thanks
I finally got it @Brian_Wilson . Then got some new ones and fixed those also.
First
In File explorer go here C:\Program Files\ArcGIS\Pro\bin\Python\Scripts
Open powershell in this dir by Right clicking – Powershell – Open here
Then run this command
.\activate.bat
Second
Open settings.json
In VSCode Ctrl + Shift + P. Then search for settings and click the Preferences: Open User Settings (JSON)
Or close VS and go to C:\Users\[YouUserNameHere]\AppData\Roaming\Code\User and edit the settings.json with notepad
You should see a powershell section section like this - add the line
If not add all of this below