Configure VSCode and a cloned ArcGIS Pro Conda environment

2142
6
04-20-2022 01:00 PM
MichaelAugust
Occasional Contributor III

I have a cloned the default arcgispro-py3 conda environment and would like to set up vscode IDE and use it as my interpreter and in the terminal but am struggling with a few issues:

I can choose my default interpreter just fine by pointing to the python.exe inside my cloned conda environment, however the indicator at the bottom says (system) instead of (conda) - is that ok?

When I launch a terminal in vscode (or in Windows) it throws up error:

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation

but when I run "conda activate myvenv" - the command states that myvenv is already the active environment...

I guess I'm looking for pretty explicit instructions on how to configure a cloned ArcGIS Pro python environment to work with vscode, Windows PATH considerations, etc. and am a little lost. There seem to be some differences between a regular Anaconda windows installation and the way Pro sets it up.

Possibly there is a guide that someone is aware of or if someone working in this IDE could chime in that'd be great. 

6 Replies
Luke_Pinner
MVP Regular Contributor

Yes, Pro's conda executable is modified. The way I do it is have a standalone miniconda installation, point VSCode to the miniconda conda.exe and then select the arcgispro-py-clone as the project interpreter.

Luke_Pinner_0-1650756687110.png

 

MichaelAugust
Occasional Contributor III

Thanks for that suggestion, yeah that seems like a good workaround, very confusing to not have it just work like the other "conda" distributions. I've got a bug ticket open with the vscode python extension too because the conda.exe doesn't close correctly on Windows when you shutdown vscode. Beginner here, and I wish there were some ESRI sponsored instructions on how to set up vscode correctly with python since it's so popular and the settings are kind of a nightmare. Cheers!

PhilipOrlando
New Contributor III

@MichaelAugust, are there any updates you can share on this? Currently troubleshooting the same issue and would appreciate any pointers. Thanks!

0 Kudos
MichaelAugust
Occasional Contributor III
No, but there's this thread that i think might help...I honestly haven't gone back it was so painful.

https://community.esri.com/t5/python-questions/trying-to-configure-arcgis-pro-arcpy-vs-code-but/m-p/...
[https://community.esri.com/html/assets/EsriCommunity.jpg]<>
Re: Trying to configure ArcGIS Pro/ArcPy + VS Code, but can't activate conda environment - where am I going wrong?<>
You da man, - thanks for replying, this worked for me! I had a very frustrating call with an Esri tech support representative for an hour trying to work thru this, but it ultimately ended it with a "we don't support this" answer and the ticket being closed I probably wasn't communicating things ef...
community.esri.com

DougBrowning
MVP Esteemed Contributor
0 Kudos
DaleBrooks
Esri Contributor

These are my VS Code settings I used (with cmd.exe as the default shell):

  "python.condaPath": "C:\\Users\\<myusername>\\Miniconda3\\Scripts\\conda.exe",
  "python.defaultInterpreterPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\<my cloned py3 dir>\\python.exe",
  "terminal.integrated.defaultProfile.windows": "Command Prompt",
  "terminal.integrated.profiles.windows": {
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [""],
      "icon": "terminal-cmd"
    }
  }
0 Kudos