# Change which default python install runs .py scripts a the command prompt

I have 3 installations of python on my machine currently, the ArcGIS install, the QGIS install, and an Anaconda install. The Anaconda is the on that I use predominantly. If I run a .py script (checkSource.py) with the following lines at the command prompt I get different results depending how I call it :

import sys
sys.prefix

C:\Users\RDebbout> checkSource.py
'C:\Python27\ArcGISx6410.3'

C:\Users\RDebbout> python checkSource.py
'C:\Users\RDebbout\AppData\Local\Continuum\Anaconda'


Will running .py scripts at the command line always search for the C:\Python27 install first? Is there a way to change this? I never do anything with the ArcGIS install other than import arcpy into the Anaconda install through the .pth file and would like to keep it sidelined from being used at the command prompt, so if I run a .py file there I want it to default to the Anaconda install, not the Arc install

• C:\Python27\ArcGISx6410.3\python.exe C:\Users\RDebbout\checkSource.py etc. – Midavalo May 16 '16 at 18:33
• this is a solution to explicitly call which python to use when running a script, however I am looking for a way to set up my environment variables so that it doesn't find the ArcGIS python when running the .py file. – rickD May 16 '16 at 18:56

## 1 Answer

You can do this with a batch file by explicitly pointing to your ArcGIS install:

start C:\Python27\ArcGIS10.3\python.exe C:\Path\to_the\script\to_run.py


You can apply the same logic to the cmd and point it to your desired python interpreter...If you are using a more robust Python IDE, you may even be able to point that to which version to use when running your script.

• +1 When setting up scheduled tasks, I ALWAYS explicitly point to the full path of python.exe that I am wanting to use. And yes, in some IDEs (PyCharm, for example), you can set the interpreter on a per-project basis for use in dev and testing. – Chad Cooper May 18 '16 at 15:48
• Yes, I do this too just to be safe...explicit is better than implicit :) – crmackey May 18 '16 at 15:51