我在设置我的开发环境(PyCharm 的最新版本社区构建)时遇到问题。一直在用以前的版本写python脚本做ArcGIS处理。为此,您需要导入 ArcGIS python API - arcpy。这一直很好,但现在我似乎无法直接访问 arcpy。
我已将 ArcGIS 位置添加到我的 python 路径、我的项目设置路径并且可以实例化 arcpy 对象的实例,但尝试与顶级方法或类交互会生成套接字服务器错误(如下)。例如来自交互式提示:
>> 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
但是 - 如果我忽略它并实例化 map 文档的实例
>>import arcpy
>>fullpath = r'C:\Temp\some.mxd' # where this is a valid ESRI map doc
>> my_mapdoc_object = arcpy.mapping.MapDocument(fullpath)
我现在可以与该对象进行交互了。 我在设置环境时做错了什么?
请您参考如下方法:
似乎是 PyCharm 被绊倒的文档字符串问题。
在 arcpy 中,在其中一个工具函数的文档字符串中,数据路径中有一个转义字符,特别是\a。如果更正,错误就会消失。
