Configure VSCode and a cloned ArcGIS Pro Conda environment

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

0 Kudos
3 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!

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