python -c import time; t1 = time.clock(); import arcpy; print('{0} seconds'.format(time.clock() - t1)) 3.60283379862 seconds

It takes this long each time i launch my script or test.

Is there any way to make import faster? Probably somehow cache arcpy module in memory between launches?

OS - Windows 7.

  • You could try this building a simple server/client for imports – geodranic Feb 11 '16 at 5:08
  • As many of the proposals require a running cmd-shell, why not using a simple cmdline inside the script? The modul cmd is a standard modul and easy to use. – Andreas Müller Feb 11 '16 at 8:27
  • Steven, thanks, i have my script working on production and test (my computer) environments. Even if i use client&server approach on test, i have to use usual 'import arcpy' on prod, so i have to maitain two different ways in my script to interact with arcpy. Also with client-server it is unclear for me how to return results of arcpy's functions calls and how to get errors. – Doctor Coder Feb 11 '16 at 8:46
  • Andreas, excuse me, but i'm not sure i understand, what you're trying to offer. – Doctor Coder Feb 11 '16 at 8:50

If you're able to execute import arcpy in under 4 seconds, the DLL files are already cached in memory, and that's as fast as you can hope to achieve. It's a very large library, and it takes Python a while to read and register. The best way to reduce repeat import cost is to not exit().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.