Select to view content in your preferred language

'Import arcpy' error (RuntimeError: NotInitialized) when using IDLE

23353
24
02-18-2011 01:37 AM
RachaelYule
Emerging Contributor
ArcGIS Version: ArcGIS 10, Python 2.6.5 Machine: Windows 7 64bit (Intel)

I'm receiving the following error when importing arcpy using the the IDLE (gui and cmd prompt) and when using pythonwin.

I had removed python26 and python25 from my system and have done a fresh install of ArcGIS 10 and python. Therefore am calling IDLE from here: "C:\Python26\ArcGIS10.0\pythonw.exe"

The Error:

**IDLE 2.6.5

import arcpy Traceback (most recent call last): File "", line 1, in import arcpy File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy__init__.py", line 17, in from geoprocessing import gp File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing__init__.py", line 14, in from _base import * File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing_base.py", line 568, in env = GPEnvironments(gp) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing_base.py", line 565, in GPEnvironments return GPEnvironment(geoprocessor) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing_base.py", line 521, in init self._refresh() File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing_base.py", line 523, in _refresh envset = (set(env for env in self._gp.listEnvironments())) RuntimeError: NotInitialized**

EsriUK and Esri tech support have recommended fresh reinstall and registry edits = but this has not worked. I'm waiting on them for a solution.

I've investigated whether it was a module arcpy path issue. There are a couple of links on the Esri forums and on the ArcGIS help regarding paths. Also, a possible related thread on gis.stackexchange.

I followed the advise from 'kimo' on the Esri forum thread. But still the import error.

My system variable (that I've edited) is: PYTHONPATH = "c:\python26";"C:\Python26\ArcGIS10.0";"C:\Python26\ArcGIS10.0\Lib\site-packages";"C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy"

I have checked I have the contents of "C:\Python26\ArcGIS10.0\Lib\site-packages\Desktop10.pth". The contents are: C:\Program Files (x86)\ArcGIS\Desktop10.0\bin C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Scripts

However, the traceback message shows that a .py script is found in the folder: C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy. Therefore, suggests the arcpy module is found by the interpreter but then not initialized(?).

Arcpy can be called from the Python Window within ArcMap and ArcCatalog okay. It is only when called from a Python interpreter that the 'import arcpy' fails. Therefore, arcpy is initalized okay by ArcMap/ArcCatalog, but not IDLE - how can this be?

I previously had an install of python25, then python26 then after that upgraded to ArcGIS 10. Therefore, there was quite a lot of legacy python on my machine. However, I've uninstalled all and registry cleaned using ccleaner.

I've posted on GIS.stackexchange too.

Can anyone suggest another line of enquiry as I'm not experienced with python enough to solve initialize/runtime errors? I'd like to avoid reinstalling the OS too!

Cheers Sam
Tags (2)
0 Kudos
24 Replies
V_StuartFoote
MVP Alum
Sam,

Sorry, I'll leave a zip'd copy of the FNPLicensingService.exe at the ftp link below for you for a day, so you can try to recreate the C:\Program Files (x86)\Common Files\Macrovision Shared\FLEXnet Publisher to bring ArcGIS back up.

<link deleted-vsf>/FNPLicensingService.zip

And also you should recreate the fnp_registrations.xml file with this text:
<?xml version="1.0" encoding="UTF-8" ?>
<Activation_Service_Users>
<Publishers>
<Publisher>
<Name>ARCGIS</Name>
<Products>
<Product>ARCGIS</Product>
</Products>
</Publisher>
</Publishers>
</Activation_Service_Users>


Obviously, a complete uninstall/registry & folder cleanup/reinstall should be more certain than the ArcGIS repair install. Repairing the FlexNet Publisher component outside the installer is going to be dodgy and might still leave unresolved issues with the license calls from ArcPy in IDLE.

It is a bit murky, but seem to recall someone at Flexera tech support had told me that the FNPLicensingService.exe was vendor deployed--not a generic, and would be included in libFNP.dll

So, not exactly a FlexNet Publisher repair tool, but if you look in C:\Program Files (x86)\Common Files\ArcGIS\bin you'll see the ArcGIS Administrator and the FNP License components, they're paired--an executable and a DLL:

ArcGISAdmin.exe -- ArcGISAdmin_libFNP.dll
SoftwareAuthorization.exe -- SoftwareAuthorization_libFNP.dll
LicenseUtil.exe -- LicensUtil_libFNP.dll

I can't check an install log at the moment, but I assume that the ArcGIS Desktop 10.0 installer first lays down this folder and then runs a script to put down the FNPLicensingService.exe in Macrovision Shared--probably calling the LicenseUtil.exe but I can't test that.

So unless someone from ESRI pipes up with details of a manual install & recovery--best bet would probably be to do a complete ArcGIS Desktop 10.0 uninstall--deleting the ArcGIS Common Files & the ArcGIS Publisher stanzas from the Macrovison Shared\FLEXnet Publisher fnp_registrations.xml (if still intact).

And if you go that far, probably best to uninstall Python2.6 and clear the registry and delete any file remnants of that as well. Along with your per-user HKLM_CURRENT_USER\SOFTWARE\ESRI registry settings and the C:\Users\<yourusername>\My Documents\ArcGIS and C:\Users\<yourusername>\AppData\Roaming\ESRI folders.

I'm pretty comfortable saying that uninstalling, clearing the registry and deleting any residuals followed by a Desktop 10.0 & Python 2.6.5 reinstall from ESRI media and reactivation WILL put everything right.

The ONLY reason to have gone through this much pain to bring the Python licensing function back online would have been to keep the SU activation intact--that seems unlikely. So doing the uninstall/clean-up/reinstall is becoming more practical.

Stuart
0 Kudos
RachaelYule
Emerging Contributor
Hi Stuart - thanks for the link - managed to reauthorise ArcGIS.

Unfortunately, I've waived the white flag I'm afraid! I've sent the machine for a full rebuild of the OS.

I uninstalled about 50% of my applications (major ones like ArcGIS, Visual Studio and any I could see that were developed using python, eg Inkscape & Blender), in the hope that helped. Gutted the registry of all Esri/ArcGIS keys and removed associated folders.

After a complete install of ArcGIS Desktop, still the error. I couldn't believe it!

Really appreciate your time and efforts on this. I've learnt a lot regarding the inner workings of ArcGIS! The turn around time for my machine is two days = therefore probably the best bet. Hate giving up though.

Great support - thanks.
Cheers-Sam
0 Kudos
RachaelYule
Emerging Contributor
After a full format of the hard drive and reinstall of the operating system and ArcGIS = problem fixed.
0 Kudos
V_StuartFoote
MVP Alum
Sam,

Sorry that was so painful for you. I hope you didn't loose too much with the reimage.

With the fresh load, look through the litany of "adjustments" needed for Windows 7 over on the Desktop - Installation, configuration forum--and be sure to apply SP1 and patches.

Stuart
0 Kudos
DrewDowling
Frequent Contributor
I ran into this error when I tried to run a script without first having set the license server using the ArcGIS Administrator tool.
0 Kudos