Select to view content in your preferred language

File Location of ArcGIS API for Python?

1372
4
Jump to solution
01-25-2023 11:24 AM
AllenDailey1
Frequent Contributor

Please help... I have done so many google searches for this and... nothing.  Whyyyy?  

What is the file/directory location or path of the ArcGIS API for Python, particularly on an ArcGIS Server? 

I am having extremely mysterious failure with a standalone script that is trying to use the API to stop services, so I want to find some way to check if the API really exists on this server where I'm running the script.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Try

import arcgis
print(arcgis.__file__)

jcarlson_1-1674677724088.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

Try

import arcgis
print(arcgis.__file__)

jcarlson_1-1674677724088.png

 

- Josh Carlson
Kendall County GIS
AllenDailey1
Frequent Contributor

Thank you so much!  Whoops, it had not occurred to me to do something like that.  It worked!

0 Kudos
Brian_Wilson
Honored Contributor

I am using 10.9.1 Server and so https://enterprise.arcgis.com/en/server/10.9.1/develop/windows/scripting-service-publishing-with-arc... says where python lives and I can do this

'C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts\propy.bat'
>>> import arcgis
>>> arcgis.__file__
'C:\\Program Files\\ArcGIS\\Server\\framework\\runtime\\ArcGIS\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\arcgis\\__init__.py'
>>> arcgis.__version__
'1.9.1'

Other versions of python might live on your server, on mine, there is C:\Python27\ for example, which shows this,

C:\Python27\ArcGISx6410.9\python.exe
Python 2.7.18.4 (default, Sep 22 2021, 18:34:14) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcgis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named arcgis

I assume some ancient creaky Esri installer used python 2 and then it just lives on forever.

You can look at all the places searched for modules,

>>> import sys
>>> for p in sys.path:
...   print(p)
...

C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\Resources\ArcPy
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python37.zip
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\DLLs
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\Resources\ArcToolbox\Scripts
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages\future-0.18.2-py3.7.egg
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages\pytz-2020.1-py3.7.egg
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages\pywin32_ctypes-0.2.0-py3.7.egg
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages\pywin32security
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\lib\site-packages\sympy-1.5.1-py3.7.egg

 

0 Kudos
AllenDailey1
Frequent Contributor

Thank you for this information!

0 Kudos