5

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?

  • 1
    did you try going to options/settings ( i don't know what it is named for spyder, I use Pycharm) and setting the path to your arcpy? it looks like your interpreter is not finding where arcpy is located. – yanes Jan 14 '16 at 17:27
5

It'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.

  • I am using ArcGIS 10.3 and this procedure returns an "invalid file path" error message. I am using C:\Python27\ArcGIS10.3 as path. – FaCoffee Jan 9 '17 at 12:49
  • @CF84 my guess is that your Python is installed elsewhere? See if you can locate it in then update the path accordingly. – Dùn Caan Jan 9 '17 at 13:01
  • I in fact have two Python versions - one associated with Anaconda and the other with ArcGIS. How to deal with this? Never done before :) – FaCoffee Jan 9 '17 at 13:04
  • Thats what the original question was about.. You can either change the version used by Spyder (as above), or copy/install the required libraries into the Spyder version. Arcpy etc will be located in something like 'C:\Python27\ArcGIS10.4\Lib\site-packages', copy it across to your Spyder folder (something like 'C:\Program Files (x86)\Anaconda2\Lib\site-packages', or add the ArcGIS version to your pythonpath i.e. stackoverflow.com/questions/3701646/… – Dùn Caan Jan 9 '17 at 13:16
  • Thanks -- that helps. For the record, here in June 2018, running the current Spyder 3.2.8, the path to tab on which you can set the path to python is "Tools" -> "Preferences" -> "Python interpreter" -> "Use the following interpreter". – Josh O'Brien Jun 29 '18 at 19:04
1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.