import arcpy hangs

1339
4
01-16-2011 05:05 PM
GraemeBrowning
Occasional Contributor III
I have a very small test script (test.py) that I use to see if Python is installed and ready to use ArcPy. All it contains is:

print "Starting"
import os
print "OS imported"
import arcpy
print "ArcPy imported"

I�??m running it under Vista SP1 with ArcGIS Desktop 10 SP1 and the only version of Python present is 2.6.5 which was installed by ArcGIS Desktop 10.  ArcMap 10 SP1 is starting fine and the "import arcpy" and other arcpy functions work fine from the Python Window.

However, when I run �??python test.py�?� from the DOS/cmd prompt, the first two print statements execute as expected, but the last one does not, so it seems to be failing/hanging on �??import arcpy�?�.  For a brief time on two separate days the script actually ran fine, but then it seems to stop working (which to me is bizarre).  To try and figure what the problem is I have been reading �??Importing ArcPy�?� at http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z00000008000000.htm and I think I have the system variables Path and PYTHONPATH set to appropriate values:

Path=C:\Program Files\weoapp;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files\Common Files\Lenovo;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\ThinkPad\ConnectUtilities\;C:\Program Files\Lenovo\Client Security Solution;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;C:\Python26\ArcGIS10.0

PYTHONPATH=C:\Python26\ArcGIS10.0
but I�??ve also tried:
PYTHONPATH=C:\Python26

When I first noticed the problem I had both Python 2.5.x (C:\Python25) and 2.6.5 (C:\Python26) present, so I went to considerable trouble to remove both, and uninstall ArcGIS Desktop 10 SP1 before reinstalling ArcGIS Desktop 10 (which installed Python 2.6.5) and then its SP1 again.

Does anyone have an idea as to what may be causing �??import arcpy�?� to hang for me most of the time, or have any ideas as to what debugging steps may be available to me?

- Graeme
Tags (2)
0 Kudos
4 Replies
CharlesMorton
New Contributor II
Did you ever resolve this issue? 
I just started having this happen on a computer that previously worked fine.
Charles
0 Kudos
GraemeBrowning
Occasional Contributor III
I got some help from Stack Exchange ( http://gis.stackexchange.com/questions/5207/why-would-import-arcpy-hang-python-script-run-from-dos-c... ) that has helped me get this working on one Vista laptop but not another.  I'm still hoping someone may come up with a (better) solution that works on both my laptops.

- Graeme
0 Kudos
DavidMountain
New Contributor
I got some help from Stack Exchange ( http://gis.stackexchange.com/questions/5207/why-would-import-arcpy-hang-python-script-run-from-dos-c... ) that has helped me get this working on one Vista laptop but not another.  I'm still hoping someone may come up with a (better) solution that works on both my laptops.

- Graeme


I also have this problem. I have compared behaviour across two different installations: both windows server 2008 R2 / ArcGIS server 10.1.

I have pythonwin installed on both, and can run non-arcpy scripts without problems. On one machine, the following snippet ....

print "Starting"
import os
print "OS imported"
import arcpy
print "ArcPy imported"


... runs from start to end and returns exit code 0. On the other, it hangs, pythonwin enters a "Not Responding" state, and I am forced to restart the application. If I comment out the:

import arcpy


line, the script runs from start to end on both machines, returning exit code 0;.

I'm not getting much back in the way of diagnostics - no error messages, just an application hang, so struggling to find a way forward. I doubt this is due to paths, since the behaviour is a hang, rather than the error that I would expect to see if the arcpy library could not be located. The sys.path includes

'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\arcpy'


on both machines, which is a valid directory path in both cases.

I'd appreciate any advice on how to further diagnose this problem.
0 Kudos
Drew
by
Occasional Contributor III

We had this issue and it was our Anti Virus software causing it to hang.

0 Kudos