For context this is ArcGIS 10.4.1 for Desktop using arcpy python 2.7 module.
So I have been working all day messing around with arcpy to modify some shapefiles I have with no issues at all. About an hour ago, I ran the same script as I had previously been running, but this time instead of ~20 seconds to import arcpy, it wouldn't even import after 30+ minutes. I've tried restarting my IDE (PyCharm) and debugging the import code.
What I found is that at the line below, the import hangs and nothing happens after this line is reached.
envset = (set(env for env in self._gp.listEnvironments()))
In the _base.py file.
I'm not sure if this is an issue on ESRI's side with validation of my license, but this problem has persisted for over an hour so far for what seems like no reason. I made absolutely no changes to my development environment and this is the first issue with importing since I got it to work about a month ago.
Just curious, any chance you upgrade to Pro 2.1.1, or hat you are using a borrowed/offline license (for desktop or pro)? Long shot, but I've seen several issues with import arcpy suddenly being slow. Seems like one of those to items might be involved. I have a support ticket for mine. My notes are found https://community.esri.com/message/749008-re-arcpy-import-is-really-slow-2-minutes in the comments.
Yeah, I read your thread earlier in search of a solution to the issue. AFAIK, my license is a single use license for ArcGIS for Desktop Basic version 10.4 and is a permanent license (check the below image)
It's just odd to me because it had been working all day and as I said all of the last month and just randomly stopped. I just removed a new import I had previously been using for arcpy.mapping even though that import was never even reached in my code, and the import for arcpy itself continues to hang.
Within your IDE or the arcmap python window... you are saying that this doesn't even work without issue?
import arcpy arcpy.gp.listEnvironments() ['autoCommit', 'XYResolution', 'processingServerUser', 'XYDomain', 'processingServerPassword', 'scratchWorkspace', 'cartographicPartitions', 'terrainMemoryUsage', 'MTolerance', 'compression', 'coincidentPoints', 'randomGenerator', 'outputCoordinateSystem', 'rasterStatistics', 'ZDomain', 'transferDomains', 'S100FeatureCatalogueFile', 'maintainAttachments', 'resamplingMethod', 'snapRaster', 'cartographicCoordinateSystem', 'configKeyword', 'outputZFlag', 'qualifiedFieldNames', 'tileSize', 'parallelProcessingFactor', 'pyramid', 'referenceScale', 'processingServer', 'extent', 'XYTolerance', 'tinSaveVersion', 'nodata', 'MDomain', 'cellSize', 'outputZValue', 'outputMFlag', 'geographicTransformations', 'ZResolution', 'mask', 'maintainSpatialIndex', 'preserveGlobalIds', 'workspace', 'MResolution', 'baDataSource', 'ZTolerance', 'scratchGDB', 'scratchFolder', 'packageWorkspace', 'scriptWorkspace', 'addOutputsToMap']
Oddly enough, this does indeed work. However importing arcpy via my IDE (using a virtual environment with a .pth file), or even the arcgis python install python executable it will not work...
Nothing at all has been touched in my python install.
This is my zzArcGIS.pth file which has also not been modified at all and matches up with all directories listed.
# zzArcGIS.pth # Path to ArcGIS arcpy modules # Place in folder ...\<path to your virtual environment>\lib\site-packages\ C:\\Windows\\SYSTEM32\\python27.zip C:\\Python27\\ArcGIS10.4\\DLLs C:\\Python27\\ArcGIS10.4\\lib C:\\Python27\\ArcGIS10.4\\lib\\plat-win C:\\Python27\\ArcGIS10.4\\lib\\lib-tk C:\\Python27\\ArcGIS10.4 C:\\Python27\\ArcGIS10.4\\lib\\site-packages 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
Don't have 10.4, but the pth specs are listed here (you can change version)
although they look fine, but I have no clue about virtualized environment use... sorry
You may want to try what tech support had me do yesterday. It fun not fix my import in my
IDE, but did help some with my import within the Desktop soft where. I renamed the c:\python27\arcgis10.6 (10.4 for you) and then dud a reoccur on the Desktop softwhere. It rebuild the folder.
the only other thing I can think of, for me, is if an OS or network update was pushed out. It would not be the first time something like a MS update tweaked something with the GIS software.
Mine seems to be working better on one machine, but now is having an issue on another when I upgraded the IDE software. I have a ticket in with the IDE tech support to see if it is maybe anything strange things happen witht hat update (which uses Ellipse behind the scenes I believe).
edit: I'll just add this in case it help others (longer info in another thread). If you have issues, look to see if you have the
https://support.esri.com/en/Products/Desktop/arcgis-desktop/arcmap/10-6#downloads?id=7521 patch(es) installed. IF so, uninstall (at least temporarily) and reboot and see if that helps. It's the Flexara patch...having to do with the license manager.