I can't import arcpy in spyder but I don't have any problem when using PyScripter. The error that I get is:
ImportError: No module named 'arcpy'
I would prefer using Spyder, if I can solve this, any suggestions?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityIt's likely that your Spyder installation is using its own installed Python, whereas Arcpy will probably be bundled with your system installation or ArcGIS version.
You can change this by setting the path to your desired Python as Yanes mentioned above, see https://stackoverflow.com/questions/11919615/how-to-change-the-path-of-python-in-spyder. Go to preferences
-> console
->advanced settings
, and set the path there. Your ArcPy path on Windows is likely to be something like 'C:\Python27\ArcGIS10.1' depending on your version.
C:\Python27\ArcGIS10.3
as path.
"Tools"
-> "Preferences"
-> "Python interpreter"
-> "Use the following interpreter"
.
Jun 29, 2018 at 19:04
This method worked for me to install ArcPy on Spyder. I am using ArcGIS Pro.
First, open Spyder and press: shift+ctrl+alt+P to open Preferences, then go to Python interpreter, select ‘use the following Python interpreter’ and enter the path to the Python folder in ArcGIS Pro. My path looks like this: C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe
Restart Spyder. The console may now be broken.
To fix this you need to go to the start menu in windows and type ‘Python Command Prompt’, right click on Python Command Prompt and choose ‘go to location’. Once in the folder with the Python Command Prompt, right click on the Python Command Prompt and choose ‘run as administrator’.
The Python Command Prompt will now open. Into the command prompt you need to type: pip install ipykernel cloudpickle
This should run its course. Once it is finished, restart Spyder and use ArcPy!
You could clone ArcGispro conda like below:
conda creat --name arcgispro --clone="C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3"
Then, you could activate this conda env and install spyder on it. conda activate arcgispro conda install spyder
arcpy
aware.