Here's what I do for Visual Studio Code and it works out pretty well for me. I use this code in a
.cmd file to create a conda environment for my project, based off of the
arcgispro-py3 environment. This will mirror that environment, so
arcpy will work (change paths and venv names accordingly - I use a custom place to store my venvs so I really know where they all are):
cd "C:\sw\Program Files\ArcGIS\Pro\bin\Python\Scripts"
call activate root
call conda create --clone arcgispro-py3 --prefix c:/sw/conda-envs/traffic-incidents
call activate c:/sw/conda-envs/traffic-incidents
call conda install -y pyodbc
Next, tell Visual Studio Code where to look for the venvs. In
python.venvPath to where your conda envs live:
For Visual Studio, once you have created your env you can set the Python env much like you can in PyCharm in the settings. See here for more on that. Much like in PyCharm, you can also create environments directly in the Visual Studio interface.