We are trying to run a GP script on a windows server (with a Desktop license installed) from a Linux machine using ssh. Python scripts without ArcPy will run fine but a GP script with 'import arcpy' just hangs. The same is true if I log into the server using cygwin - plain python scripts run fine but if I add the arcpy import statement then the script hangs.
I assume this is something to do with the python paths.
Any experience/suggestions would be greatly appreciated.
probably... this is from my machine running arcmap 10.4.1 and ArcGIS pro 1.2 and I am using python 3.4 (you may see some python27 locations if you aren't using 3.4)
>>> import sys
>>> sys.path
['', 'C:\\WINDOWS\\SYSTEM32\\python34.zip', # just the zip
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34\\Lib\\site-packages\\pythonwin', # for pythonwin you won't have this
'C:\\Python34',
'C:\\Python34\\lib\\site-packages',
'C:\\Program Files\\ArcGIS\\Pro\\bin',
'C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy',
'C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolBox\\Scripts',
'F:\\_modules', # mine, you won't have this
'C:\\Python34\\lib\\site-packages\\win32', # you won't have this since it is installed by pythonwin
'C:\\Python34\\lib\\site-packages\\win32\\lib'] # you won't have this since it is installed by pythonwin
>>>
Note... in the above list, there are packages installed that you won't have, and you will probably have ones that aren't on the list. The only thing you need to worry about is the python folders and the Arc* folders and the *.pth files. Some people have an environment variable set... I don't
Now if you don't have Pro installed, you will have this file which includes
C:\Python27\ArcGIS10.4\Lib\site-packages\Desktop10.4.pth
contents
C:\Program Files (x86)\ArcGIS\Desktop10.4\bin
C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolBox\Scripts
F:\_modules # mine, you won't have this
If you do have PRO installed then this file will contain
C:\Python34\Lib\site-packages\ArcGISPro.pth
contents:
C:\Program Files\ArcGIS\Pro\bin
C:\Program Files\ArcGIS\Pro\Resources\ArcPy
C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Scripts
So before the advice runs fast and furious, see what the sys.path returns and then you can start figuring out what is missing
Dan - many thanks for the suggestions - my sys.path is returning :
['C:\\work', 'c:\\python27', 'C:\\Python27\\ArcGIS10.3', 'C:\\Python27\\ArcGIS10.3\\Lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.3\\bin', 'C:\\work\\ C:\\Program Files (x86)\\ArcGIS\\Desktop10.3\\arcpy', 'C:\\work\\ C:\\Program Files (x86)\\ArcGIS\\Desktop10.3\\ArcToolbox\\Scripts', 'C:\\Windows\\SYSTEM32\\python27.zip', 'c:\\Python27\\ArcGIS10.3\\DLLs', 'c:\\Python27\\ArcGIS10.3\\lib', 'c:\\Python27\\ArcGIS10.3\\lib\\plat-win', 'c:\\Python27\\ArcGIS10.3\\lib\\lib-tk', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.3\\ArcPy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.3\\ArcToolBox\\Scripts']
My Desktop10.3.pth is :
C:\Program Files (x86)\ArcGIS\Desktop10.3\bin
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolBox\Scripts
looks workable, but there is those nested folders inside your work folder c:\\work\\c:\\program... what is that for? because those folders don't have the links to arcpy