问题
I would like to use arcpy into Anaconda's Spyder. I have a full ArcGIS license, so this is not an issue. I am able to semi-import the module by way of copying the the arcpy folder out of C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy and into C:\Anaconda\Lib\site-packages, but the import is never completed because I get an error of "ImportError: No module named arcgisscripting". Is there any way for arcpy to work in Spyder?
回答1:
This is what you need to do:
Open the Python window in ArcGIS, as described here
In there run these two commands:
import sys
sys.executable
Copy the output of the last command
Open Spyder and go to
Tools > Preferences > Python interpreter
Select the option
Use the following Python interpreter
and paste there the result of step 3.
Finally go to
Consoles > Open an IPython console
. This will open a new console that will be running the same Python version that comes with ArcGIS but inside Spyder. So you could run there whatever command you can run in ArcGIS Python Window.
Note: It is possible that this doesn't work if the Python that comes with ArcGIS doesn't have the ipykernel
package.
回答2:
To address this, browse to the python27\Lib\site-packages folder, mine was located under "C:\Python27\ArcGIS10.1\Lib\site-packages", and find the file Desktop10.1.pth.
On my system, the problem was resolved by simply copying the Desktop10.1.pth file into "C:\AppData\Local\Continuum\Anaconda\Lib\site-packages".
If you are running Anaconda 64 bit, you will get a different error when you try to import arcpy because ArcGIS runs 32 bit. Therefore, you have to make sure that you have the Anaconda 32 bit installed rather than 64 bit so things match up with ArcGIS. Once the file is copied and you have Anaconda 32 bit, import arcpy should work.
回答3:
The only thing worked for me is: I just copied the arcpy folder from 'C:\Program Flies(x86)\ArcGIS\Desktop10.3' and pasted that into my '~Anaconda3\Lib\site-packages'. Now I can import arcpy into spyder of Anaconda3.
来源:https://stackoverflow.com/questions/19795469/importing-arcpy-module-into-anacondas-spyder