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

19299
24
02-18-2011 01:37 AM
RachaelYule
New Contributor II
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 Frequent Contributor
Sam,

The non-2.6 Keys should go. And everything else looks correct. 

So, I'm going to agree with Jason Scheirer that the problem is in the licensing calls. Would make sense, since the uninstall/reinstall does not necessarily clear all the Keys from the registry--you have to go back in a manually delete quite a few.

I don't think there are per-User configuration of the license in the Registry. But you could try the simple rename of the the HKEY_CURRENT_USER\Software\ESRI key, allowing it to be rebuilt. If that doesn't clear the ArcPy glitch, then the problem will likely be in the HKLM\SOFTWARE Keys.  I'd look here: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ESRI\License10.0

I'll have to do a SU install on a 64-bit system to compare against a concurrent seat, but I think the Key is either SOFTWARE_CLASS or SingleUse_Installed--with values of Viewer, Editor, Professional.  Also, I think the ESRI_SOFTWARE_CLASS environment variable, if set, can impact things.

Stuart
0 Kudos
RachaelYule
New Contributor II
Hi Stuart
Okay I've removed the non 2.6 keys.
I've renamed the Esri key in: HKEY_CURRENT_USER\Software\ESRI, and then allowed it to be rebuilt. See attached screenshot.

But no luck with the import arcpy error.

I've taken a screenshot of the other key location: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ESRI\License10.0. See attached.  Do these values look correct?  Also, see the values under: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python10.0 as well. Do these look okay?

I can't see an environmental variable named ESRI_SOFTWARE_CLASS. So I've attached an xls of all my system variables (and one user variable called 'path').  Maybe you can see an error in this these values or compare with yours?

I assume uninstalling/reinstalling just the python component of ArcGIS 10 isn't worth a try?

Cheers - Sam
0 Kudos
RachaelYule
New Contributor II
Updated. Some progress....

I just changed my licence to a (newly setup) ArcView Floating licence via ArcGIS Administrator.

Bingo. IDLE imported arcpy with no errors = therefore, clearly there is a problem with IDLE recognising the single use licence.

Unfortunately, I do not have access any extensions over the floating licence, which are essential to my work, therefore need to get the single use licence working!

After changing back to singleuse ArcView in ArcGIS Administrator, and reopening a shell causes me to get the import arcpy error again.

However, keeping the IDLE shell open even after resetting to singleuse still allows me to carry on calling arcpy functions and classes. Once arcpy is successfully imported I guess it continues to function until the IDLE session ends.

Is there anyway to interrogate/analyse my setup or possible problems when I've set the using python using the concurrent licence. Any traceback options?

After a successful import arcpy using the floating licence. I tried sys.path, see below. The first entry is a .py that I launched from the IDLE - I'll assume that's normal?

Successfully imported arcpy using floating licence:
import sys
sys.path
['W:\\Projects\\GIS\\_GISRoot\\GISUtilities\\code\\python\\scripts\\updateTextElements', 'C:\\Python26\\ArcGIS10.0\\Lib\\idlelib', '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', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\ArcGIS10.0\\DLLs', 'C:\\Python26\\ArcGIS10.0\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\plat-win', 'C:\\Python26\\ArcGIS10.0\\lib\\lib-tk', 'C:\\Python26\\ArcGIS10.0', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages']

Failed import arcpy using singleuse licence:
>>> import sys
>>> sys.path
['C:\\Windows\\system32', 'C:\\Python26\\ArcGIS10.0\\Lib\\idlelib', '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', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\ArcGIS10.0\\DLLs', 'C:\\Python26\\ArcGIS10.0\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\plat-win', 'C:\\Python26\\ArcGIS10.0\\lib\\lib-tk', 'C:\\Python26\\ArcGIS10.0', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages']

Anything incorrect here? Anyone think of another way to test this?

Getting close?! Cheers - Sam
0 Kudos
V_StuartFoote
MVP Frequent Contributor
Sam,

Yup, you're making progress.

Here is a thought, since over the weeks you've cycled through several configurations of SU and Concurrent license activations, I'm not convinced that the FlexNet Publisher Trusted Storage handles this robustly. In testing just now I had to manually remove the ArcGIS_xxxxxxxx_tsf.data cache to reestablish a stable SU authorization--fortunately our authorization codes are pretty much unlimited. Both SU and concurrent "fulfillments" are kept in this data store, and as I've dealt more with it I think it can be a problem.

Do you still have your Authorization/activation codes handy (or the .PRVC used)?

The ArcGIS Administrator Authorization Wizard has a Deauthorize button. You should try cycling through a deauthorize/authorize of your SU seats on your workstation.

Do you know how many seats you have on the license. If you have additional, you might just go ahead and do a manual removal of the activations. It will burn a set of activations though, and would have to be recovered through Customer Service. For manual removal, the trusted storage file cache is here:

[INDENT]C:\Program Data\FLEXnet\ [/INDENT]

and also edit the ArcGIS Publisher lines from here...

[INDENT]C:\Program Files (x86)\Common Files\Macrovision Shared\FLEXnet Publisher\fnp_registrations.xml [/INDENT]

You'd then reauthorize with the Authorization Wizard and your existing Authorization numbers or .PRVC file.

Be careful, because if you have used all the activations, or if the Deauthorize does not release your codes for reuse, you'll have to arrange for an ESRI UK or ESRI Redlands Customer Service rep to rearm your registration numbers. That may mean more down time.

Stuart
0 Kudos
RachaelYule
New Contributor II
Stuart. Appreciate the continued assistance. Thanks.

Reading your comments. One thing to note. I am not the bona fide administrator for floating licences for my organisation, as I don't have admin rights to the particular servers where the FlexNet Licence Manager installation sits.

So, just to check with you. Because I don't have FlexNet Licence Manager installed locally and I don't have access to the file ArcGIS_xxxxxxxx_tsf.data to delete it, as it sits on a virtual server in a different office. Does this make a difference to the import arcpy error?

I have tried deauthorising/authorising already, i.e. deauthorising one arcview ESU code, then authorising a different arcview ESU code. I have tried authorising an ESU by 'over the internet' and by downloading and using an 'authorization.respc'. Again, neither authorisations helped with the problem.

I don't think I can use the .prvc method, as when using the new customer portal (), EsriUK only allow software downloads. They have prohibited access to any licence information. However, I understand from EsriUK that access is going to be rolled out in the future. I'll try to deauthorise/authorise using a further ESU code again.

After that, I think it's got to be an OS reinstall.
Cheers
0 Kudos
V_StuartFoote
MVP Frequent Contributor
Sam,

Sorry if I was not clear. The Flexera FlexNet Publisher Trusted Storage File mechanism is used by ESRI for activation and authorization of both SU and Concurrent use products.

You'd be deleting the cache on your SU client and don't need to touch the FlexNet License Manager at all. The problem I suspect is that the TSF cache structure on your PC has been corrupted--possibly impacting the SU license activation Python calls. Since IDLE worked while on a concurrent seat activation, clearing and recreating the TSF cache for SU would either fix things--or at least eliminate it as the source of the ArcPY licensing problem.

Use the ArcGIS Administrator to release the license. Then, delete the ArcGIS entires in the two folders.

Note: ArcGIS_xxxxxxxx_tsf.data file is present on both the SU client and Concurrent use client, the source of the "fulfillment" and activation records it contains differs--directly with ESRI for the SU, or your local ArcGIS License Manager for Concurrent. It would also hold a "borrowed" activation and license for an off network Concurrent seat (e.g. a laptop).

Reboot.

Open ArcGIS Administrator --> Desktop --> Authorize Now and use your set of ESUxxxxxxxxxxx Authorization numbers to again activate & authorize. Select radio button for the correct Single use license level for your ESU code. The enter the Desktop code and the codes for the Extensions and OK to complete the FNP activation exchange.

The .PRVC (or PRVS for license servers) is just a text file that combines all the user data and authorization numbers that would be entered into Authorization Wizard. It saves time and is efficient for ESU codes that have multiple activation entitlements. At education sites, it is how we deploy the authorization codes so the users don't have to manually enter so much info (or make so many mistakes resulting in failed authorizations).

Stuart
0 Kudos
RachaelYule
New Contributor II
Hi Stuart. Thanks for the clarification.

Okay, followed your instructions:
1. Deauthorising the current SU licence
2. Delete the files: ARCGIS_0038ce00_tsf.data_backup.001 and ARCGIS_0038ce00_event.log in the folder: C:\ProgramData\FLEXnet. Note I've taken a screenshot of the contents prior the delete, attached - are these right?
3. I removed the publisher lines from the file: C:\Program Files (x86)\Common Files\Macrovision Shared\FLEXnet Publisher\fnp_registrations.xml. Note there was an additional file in there, named: FNPLicensingService.exe. Haven't touched that.
4. rebooted
5. reauthorised I different ESU code.
Result = still the import arcpy error.

I noticed this folder: C:\ProgramData\ESRI, and have taken a screenshot of the contents. Anything in there that we can edit? Notice, the date modified of the styles_idx.dat (144mb) is Jan 2011? I wonder why this date? It seems (very roughly) around the time I've started having problems - could be a coincidence though.

Finally, I noticed within ArcGIS Administrator during the reauthorisation that I had to complete my details from blank, empty input cells. This is the first time I'd noticed the input fields were blank, usually they are complete. I think, even on a full uninstall/reinstall of ArcGIS Desktop, the fields were complete with my details.

Cheers
0 Kudos
V_StuartFoote
MVP Frequent Contributor
Sam,

Hmmm... thinking about the FNPLicensingService.exe,  normally I don't touch it because it is used by all the applications calling FlexNet Publisher. But, as I install each application, I keep a backup copy of the FNPLicensingService.exe installed by each application. The reason is that the copy in the Macrovision Shared common folder gets clobbered by the latest application installed that uses FNP.

I noticed you have Bently and Autodesk products installed--did you notice additional entries in the fnp_registrations.xml?

What happens if you shutdown ArcGIS (and Bently Microstation, and Adobe Acrobat--anything mentioned in the .xml) and  then rename the FNPLicensingService.exe?   I think a new copy should get added from cache when you launch ArcGIS Desktop.  Then see if that happens, and also what results when you try an import arcview, import ArcPy in IDLE.

Regards the blank fields--that data along with the "fulfillment" records are contained in the TSF files that get rebuilt during the Activation/authorization exchange process, files are all encrypted so can't be tampered with--they're dependent on FNPLicensingService.exe and libFNP.dll to manipulate.

Stuart
0 Kudos
RachaelYule
New Contributor II
Hi Stuart...getting closer!

Your question = I've downloaded trial copies of Bentley, Autodesk 3DS Max and Tableau Public in the past. I use none of these now. Below is a copy of the now existing fnp_registrations.xml. Here's the contents of fnp_registrations.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<Activation_Service_Users>
<Publishers>
<Publisher>
<Name>Autodesk</Name>
<Products>
<Product>Autodesk 3ds Max 2011 32-bit</Product>
</Products>
</Publisher>
<Publisher>
<Name>Tableau Software Inc.</Name>
<Products>
<Product>Tableau Public 5.1</Product>
</Products>
</Publisher>
</Publishers>
</Activation_Service_Users>

Only Autodesk 3DS Max and Tableau Public are mentioned.

Next, I've just renamed the FNPLicensingService.exe after close all apps.

Interesting (this may have been the case a few steps ago though). Using IDLE and import arcview and import arcpy calls, I don't get the normal import arcpy RunTime error (going back through the thread I reported this on 02-20-2011 02:45 AM). However, when try calling any arcpy functions/classes, they fail. E.g when I try an export statement on a mxd. The IDLE throws a restart message and does not complete the export?

But, launching ArcMap/ArcCatalog = I get the attached licence error message and neither application opens. So that rename definitely did something. Also, importantly no new FNPLicencingService.exe was created. Renaming back to FNPLicensingService.exe. ArcMap opens fine under SU licence.

Bingo. Doesn't this mean that neither a new SU authorisation nor a new installation of ArcGIS Desktop DOES NOT CREATE A NEW FNPLicensingService.exe file. This is confirmed by the date modified = 14/06/2010. This is, I think, the date when I installed ArcGIS for the first time on this machine or thereabouts.

Corrupted FNPLicensingService.exe file causing the problem? How about uninstalling everything that FlexNet uses (including ArcGIS) and reinstalling ArcGIS which hopefully creates a brand new FNPLicensingService.exe file?

Or is there a FlexNet repair function?

What do you reckon? Cheers - Sam
0 Kudos
RachaelYule
New Contributor II
Hi Stuart...again for more info...I've uninstalled Bentley, AutoDesk 3DS max and Tableau Public and rebooted.
1. Now, there is no folder 'Macrovision Shared' in C:\Program Files (x86)\Common Files.
2. I can't open arcMap/arcCatalog - I get the attached licence error.
3. I can't authorise a SU licence with a ES valid code. See attached error. I tried a second ESU code just to check it wasn't a limit issue.

Also, the two ArcGIS files are still in: C:\ProgramData\FLEXnet, though.

Clean uninstall/reinstall of ArcGIS Desktop or maybe a 'repair' using the install DVD?

I'll check for a reply later, it's 19:00 here. Cheers Sam
0 Kudos