Cannot import a module (arcpy)

I am having trouble with setting up my development environment (the latest release Community build of PyCharm).  I have been using the previous version to write python scripts for ArcGIS processing.  To do this you need to import the ArcGIS python API - arcpy.  This has always been fine but now I can't seem to access arcpy directly.

I have the ArcGIS location added to my python path, to my project settings paths and can instantiate an instance of an arcpy object but trying to interact with top level methods or classes generates a socket server error (below).  For example from the interactive prompt:

import arcpy - will work

but typing
arcpy. - will instantly generate


Traceback (most recent call last):

  File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 295, in _handle_request_noblock
Exception happened during processing of request from ('127.0.0.1', 59487)
    self.process_request(request, client_address)

  File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 653, in __init__
    self.finish()
  File "C:\Python27\ArcGIS10.3\lib\SocketServer.py", line 712, in finish
    self.wfile.close()
  File "C:\Python27\ArcGIS10.3\lib\socket.py", line 279, in close
    self.flush()
  File "C:\Python27\ArcGIS10.3\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] An established connection was aborted by the software in your host machine

However - if I ignore this and instantiate and instance of a map document for example

import arcpy
fullpath = r'C:\Temp\some.mxd'    # where this is a valid ESRI map doc
my_mapdoc_object = arcpy.mapping.MapDocument(fullpath)


I can now interact with the object.
What am I doing wrong with setting up my environment?
2 comments
Comment actions Permalink

Having the exact same issue. Did you ever get this resolved?

running PyCharm Community Edition 2016.1.4

arcgis 10.4.1

0
Comment actions Permalink

I did get it resolved - but never worked out exactly what the problem was.  I'm pretty sure it was a confusion in settings between the 64bit operating system and the 32bit python environment and my old pycharm settings.  I don't remember the specifics but it was something like:

  • deleted my settings.jar file out of desperation
  • applying whatever latest patches for PyCharm was available
  • then set up a new project from scratch carefully matching python interpreter versions and locations with the system environment variables

Sorry can't be more concrete - was a while back.  I did get it working so you should be able to get it back on track.  Arcpy is frustrating enough but when your IDE can't help you debug it really isn't much fun.

 

0

Please sign in to leave a comment.