0

I am using python and conda within ArcGIS Pro 2.2, but am running into some problems with virtual environments. I have cloned a copy of the Arcgis Pro environment (hereafter clone). When I activate clone in the home folder for the original ArcGIS environment (C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3), the python executable is located at C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe. However, if I activate clone in any other location, the clone looks to the clone's home folder and activates that version of python (located at C:\Users\RDCERWAW\AppData\Local\conda\conda\envs\gee\python.exe). This is causing problems because import arcpy works when I run the python.exe located at .\arcgispro-py3, but not when using the python.exe located at .\gee. Even when I modify the PYTHONPATH to include the path the .\arcgispro-py3\python.exe, the other location is accessed first. I could always start the clone in the .\argispro-py3 folder, but unfortunately spyder keeps looking back at .\gee.

Does anyone know how to code conda so that it look in a specific location first?

user44796
  • 1,053
  • 1
  • 11
  • 20
  • I believe you have to modify the PATH environment variable, not PYTHONPATH, for Conda to recognize the right Python. Take a look at this [question](https://stackoverflow.com/q/34030373/9987623). – AlexK Mar 20 '19 at 21:35

1 Answers1

0

If you're using sys.path.append(<preferred path>), try using sys.path.insert(0, <preferred path>) instead.

From what I've read, Python searches each path in the order it appears in sys.path.

mRotten
  • 447
  • 1
  • 4
  • 11
  • The problem there is that you have to start python to do this. I need to do it at the command prompt (or within the conda environment), so that when I start python, it is pointed to the correct executable. – user44796 Mar 20 '19 at 20:15
  • Ah, yep this is a path for the python.exe executable. Please disregard. – mRotten Mar 20 '19 at 20:27
  • So I am not sure what to do with this question. I have solved my problem and posted the answer at https://gis.stackexchange.com/questions/316029/arcgisscripting-module-not-found-in-python-3-5-in-spyder-ide, and I didn't have to solve the issue that I was running into in this specific question – user44796 Mar 21 '19 at 15:29