When I import arcpy under the ArcGIS 10.5 python interpreter, it is REALLY slow! I am seeing times of 149 - 197 seconds. Every once in a while, it will import in about 2.5 seconds, but the 2-3 minutes times are more typical. Further info:
Here is what I am doing to test the timing (plus using my wristwatch with ArcGIS Desktop):
import timeit
start = timeit.default_timer()
import arcpy
from arcpy import env
from arcpy.sa import *
imports = timeit.default_timer()
print("completed arcpy imports: {} sec".format(int(imports - start)))
Ideas? Thanks!
Solved! Go to Solution.
my machine... import arcpy test. Now remember, when importing it is only the first import that counts... importing the second third etc times are not relevant since the import is ignored since the namespace is taken...
So, reboot, Python 3.6, ArcGIS PRO 2.1 setup ... arcpy is largely the same, Spyder IDE.
%timeit -n1 -r1 import arcpy
6.32 s ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)
A whole 6 seconds.
Can't test in a 2.7 environment since I have used python 3 for all my code development since I can remember (even though my tools run from within arcmap use 2.7.x)
As for the import numpy in 2.7 for arcmap 10.6... hmm again, I would have to set up an IDE to work with python 2.7. I will try that tomorrow
You have a borrowed license, I assume from your work. When you are at work on your work's local network, are the times faster than when you are off your work's local network? If you completely disconnect from all networks, i.e, including any wi-fi connections, does it import faster?
Although a borrowed license allows you to work off network, ArcGIS Desktop still tries to connect to the license manager and communicate with it. If you are connected to a network, but not your work network, the client will try to communicate with the license server but won't be able to resolve the server's name if the server is on an internal work network. ArcGIS Desktop will wait for a network timeout before giving up and moving on with the use of the borrowed license.
What I typically do is borrow a license and then clear out the license manager name in ArcGIS Administrator. Without a license manager defined, ArcGIS Desktop cannot try to communicate with it. Since borrowed licenses are automatically reclaimed by the server once they expire, you don't have to worry about actually returning the license for the server to get it back. This workflow has some disadvantages, but it can greatly speed up opening ArcGIS Desktop depending on the type of network you are connected to.
Joshua - This is exactly the issue. Here are the results of my tests to import arcpy:
Opening ArcMap is about the same. It gets stuck on "Initializing License" on the splash screen.
Following your solution was exactly the issue. The reason it took me so long to reply was that I couldn't figure out your suggestion of removing the info for my license manager. The textbox where I would enter it is disabled and so is the "Change" button, so I couldn't edit them.
Then, I remembered that I am not an administrator on my PC. I located the ArcGIS Administrator in my Windows Start menu, right-clicked on it, and chose "Run as administrator". The textbox is still not editable, but the change button works now.
thanks! David
Thank-you! This was driving me bonkers! I suspected the timeout trying to connect to license manager, but it hadn't occurred to me to simply remove the license manager hostname from ArcGIS Administrator.
Although this may be unrelated, this is what finally fixed many of my issues, including the "import arcpy" issue on one of my machines. The real issues, I believe, is the external IDE was having an issue accessing the ArcGIS license.
For me, I have to uninstall the Flexara patch for the license manager that was a "highly recommended for all users" last fall. https://support.esri.com/en/Products/Desktop/arcgis-desktop/arcmap/10-6#downloads?id=7521 It says 10.6, but it is for all version back to 10.0. It looks like there was a January 2018 update, and I no longer see the "recommended that all users install" text, so I'm still trying to get clarification on that.
Anyway, if you have those Flexara patches showing in your Control Panel->Add/Remove, try uninstalling them and doing a reboot. if that does not help, try deleting the ArcGIS_* files in the c:\ProgramData\FLEXnet folder. I'm not sure which did the try for sure (did both before the reboot), but now things seem to be working better.
I'll come back with info re: the patch if/when I find out more.