简体   繁体   中英

Python ArcGIS ArcPy RuntimeError: NotInitialized

Not sure if I am posting in the right place, but I am having problems getting my python GIS programs to work on Windows 7 64 bit. These programs worked on XP 32 bit. I've done a lot of research and tried changing my PythonPath, moving the lib folder, etc and other suggestions. I made a new key in the registry under Python26 as suggested by another with the contents of the Desktop10.pth file. However I am still getting the same error posted below. I am currently running ArcGIS 10.0. I am probably missing something simple! Any help would be greatly appreciated! Thank you in advance.

Traceback (most recent call last): File "Z:\\Desktop\\GISClimateMapping.py", line 85, 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__in it__.py", line 14, in from _base import * File "C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy\\arcpy\\geoprocessing_bas e.py", line 568, in env = GPEnvironments(gp) File "C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy\\arcpy\\geoprocessing_bas e.py", line 565, in GPEnvironments return GPEnvironment(geoprocessor) File "C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy\\arcpy\\geoprocessing_bas e.py", line 521, in init self._refresh() File "C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy\\arcpy\\geoprocessing_bas e.py", line 523, in _refresh envset = (set(env for env in self._gp.listEnvironments())) RuntimeError: NotInitialized

I had a very similar problem. We have a single licence which, if it's checked out to someone else, prohibits my script from running. I've found this empirically rather than through code/support but I'm fairly confident that's your issue.

You must use Python 2.6 32 bit with Arcgis 10.0, even with a 64 bit OS. I suspect (though not sure from the info provided) that you have another version of Python installed. I would first check to see how many versions are installed, and uninstall all of them except the one at C:\\Pytho26\\ArcGIS10.0. Then I'd install Python 2.6 (it's on the ArcGIS disk) at the location mentioned. You'll need to re-install numpy and matplotlib too, which are also on the disk. If that does not help, then I'd uninstall ArcGIS and every Python version on your machine, and then re-install ArcGIS. This sounds drastic, but ESRI's Python implementation is pretty sensitive, and you can waste days on trying to find an easy fix. This last step usually works.

I had this very error when the first line of my code was "import arcpy", and the solution for me was to insert a new first line to my python script: "import arcview".

My code was running fine on a system using ArcGIS 10.0, but ran into this problem after I upgraded my development box to 10.1 desktop and server. Various stackoverflow, gisstackexchange, and forums.arcgis.com articles pointed to PATH, PYTHONPATH, HLKM etc environment possibilities or checking your ArcGIS Administrator licensing. After reproducing the problem in both pyscripter and IDLE, confirming everything was as it should be with a properly uninstalled python 2.6, an installed python 2.7 environment, and a valid floating license the error still persisted. My best conjecture for why this fix worked is that perhaps starting with 10.1 arcgis license checkout may be more explicit.

For the record, I just encountered this problem in 10.1 while debugging an arcpy script in Visual Studio. It actually happened between runs with no code changes - one run worked, the next got the error. For whatever reason, adding the import arcview to the top worked. Maybe it is a license checkout issue, but such inconsistency is troubling.

Strange but true. Had the same problem after upgrading ArcGIS (ArcInfo) 10.1 to 10.2. Added one line in the python code:

import arcinfo

After this everything worked perfect. Easy to fix, hard to understand.

Thanks! Willem

I think the problem was created by another user running ArcMap at the same time - since there is a single ArcGIS licence. When the user closed ArcMap in fact, the python script started running well.

This error might occur because your Python is 64-bit and your ArcMap 32-bit.

You can either update your python to a 64-bit version or update you ArcMap to a 64-bit.

How to get a 64-bit version of ArcMap:

  • From install. When you launch the autorun.exe application, the startup window wil give you the option of installing ArcGIS Desktop Background Geoprocessing (64-bit). This is only available in versions 10.1 and above
  • If you already have ArcGIS Installed in your computer. You can download a patch for the Background Geoprocessing (64-bit) here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM