How to use arcpy module in Anaconda's install of Spyder?

北城以北 提交于 2020-01-15 12:14:07

问题


I recently installed Anaconda's Python distribution, which includes Spyder IDE. I am interested in importing the ArcGIS 10.3 arcpy module in Spyder. Unfortunately, running import arcpy results in the following error:

import arcpy
Traceback (most recent call last):

  File "<ipython-input-2-50d283eebbb3>", 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 14, in <module>
    import arcgisscripting

ImportError: No module named arcgisscripting

To resolve this error, I have tried 1) changing the interpreter to ArcMap.exe and 2) moving the Desktop10.1.pth file, both as shown in this SE post. Solution #1 crashes Spyder and solution #2 has no effect.

What steps are needed to be able to import and use the arcpy module in the Anaconda distribution of Spyder?


回答1:


A good explanation on how to do this here

To allow other Python installations to access Arcpy a file must be copied from the \Lib\site-packages\ folder within the Arc Python installation and placed in the corresponding folder of the non-Arc Python. If you have not installed 64-bit background geoprocessing the file is Desktop10.1.pth; if you have installed it, the file is DTBGGP64.pth.

I strongly recommend reading that post.



来源:https://stackoverflow.com/questions/28789526/how-to-use-arcpy-module-in-anacondas-install-of-spyder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!