[GIS] import arcpy failed Python 2.7 with ArcGIS 10.3 64-bit Background geoprocessing RuntimeError: NotInitialized

#memory#error64bitarcpybackground-geoprocessingpython-2.7

I want to run a python script that uses arcpy. It was running earlier on a 32-bit machine without problems. On a 64-bit machine I get a MemoryError. The 64-bit backgroundgeoprocessing of ArcGIS 10.3 should solve this problem. If I type import arcpy to the IDLE which is 64-bit too I get the following error message:

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in <module>
    import arcpy
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 598, in <module>
    env = GPEnvironments(gp)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 595, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 551, in __init__
    self._refresh()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 553, in _refresh
    envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized

To make sure I installed everything correctly:
ArcGIS 10.3 (Advanced Concurrent License);
ArcGIS 10.3 64-bit backgroundgeoproessing patch;
Python 2.7.9 x64

I also adapted the system paths fron …\bin to \bin64 and from Python27\ArcGIS10.3 to \ArcGISx6410.3

Best Answer

10.3 does not use 2.7.9. For this reason I can tell you've installed your own Python. If you install your own, you need to have made sure you've installed numpy, matplotlib and a couple more packages that escape me right now.

Quite honestly, the easiest way to "fix" this is to go back and start from scratch.

  • uninstall BG
  • uninstall Python 2.7.9
  • remove the entries you've created in the path that point to Python
  • just install BG64. Thats it. no pointing of paths, no worrying about getting the right packages. The installer will make sure everything gets laid down in the correct spot.

Right now you're going to play whack-a-mole trying to find what piece you have that is pointing at something incorrectly.

If you absolutely do want to play the game of trying to fix it...its probably an issue with your paths. Instead of adding to your system path, BG uses a .PTH file, generally located here when you have a default install: "C:\Python27\ArcGISx6410.3\Lib\site-packages\DTBGGP64.pth"

Inside the file will be 3 lines:

C:\Program Files (x86)\ArcGIS\Desktop10.3\bin64
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolBox\Scripts

If you replicate this workflow with the file and these paths in your site-packages directory, it may lead you in the right direction.