ArcPy Module not loading in Command Line

4274
12
03-22-2016 12:13 PM
AngelaBozeman
New Contributor III

I installed ArcMap 10.3.1 on a Windows 10 computer (using Python2.7.8) and arcpy imports properly in ArcMap and the Python IDLE but gets hung up when using command line. When importing, the cursor flashes like it's working but nothing ever happens. I have made sure the System properties reflect the path to the python folder and that the Desktop10.3.pth is correct. Any suggestions are appreciated.

Tags (1)
0 Kudos
12 Replies
curtvprice
MVP Esteemed Contributor

Compare the sys.path you are getting from IDLE from the one you get from the command line. That may help you figure out what's going on.

import sys
print(sys.version)  # active version of python
print(sys.prefix)   # python exec path
print("\n".join(sys.path))  # current  path setting used by import
AngelaBozeman
New Contributor III

When running in Command Line vs. IDLE the only difference in the two print statements is IDLE prints C:\windows\SYSTEM32 and C:\Python27\ArcGIS10.3\Lib\idleLib while command line does not have those lines. I tried adding C:\Python27\ArcGIS10.3\Lib\idleLib to the PTH in my system environment variables but it didn't seem to change anything.

Here is what the IDLE print statements look like.

****VERSION****

2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]

****PREFIX****

C:\Python27\ArcGIS10.3

****CURRENT PATH****

C:/deleteme

C:\windows\system32

C:\Python27\ArcGIS10.3\Lib\idlelib

C:\windows\SYSTEM32\python27.zip

C:\Python27\ArcGIS10.3\DLLs

C:\Python27\ArcGIS10.3\lib

C:\Python27\ArcGIS10.3\lib\plat-win

C:\Python27\ArcGIS10.3\lib\lib-tk

C:\Python27\ArcGIS10.3

C:\Python27\ArcGIS10.3\lib\site-packages

C:\Program Files (x86)\ArcGIS\Desktop10.3\bin

C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy

C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolBox\Scripts

Capture.PNG

0 Kudos
DanPatterson_Retired
MVP Emeritus

that is correct for python 2.7 installed version for arcmap

0 Kudos
curtvprice
MVP Esteemed Contributor

That is strange. Two more thoughts, don't know if they are worth much...

  • I didn't think 10.3 was supported under Windows 10.
  • If you are using a different Python than that shipped with ArcGIS I recommend uninstalling it and doing a repair install of ArcGIS to install Esri's python just to make sure everything is in synch.
0 Kudos
AngelaBozeman
New Contributor III

I have to run ArcGIS 10.3.1 in compatibility mode for it to run properly but I haven't had any issues with ArcGIS 10.3.1.

I am using the python that is installed with ArcGIS (Python 2.7.8) and I actually uninstalled the python 3.4 that also came with the ArcGIS installation in the event that is was causing confusion.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Python 3.4.x comes with ArcGIS PRO and both python 2.7.x and python 3.4.x live quite happily in either ArcMap 10.3.1/10.4 or ArcGIS Pro 1.1/1.2.  The import thing, other that messing around with other distributions etc, is when what was installed and how you manage them.  In a simple world, ArcWhatever would be installed and install whatever version of python it needs.  When things go weird is when things don't follow the expected order of progression from an Arc* perspective.

0 Kudos
FredSpataro
Occasional Contributor III

It could be a UAC issue... did you try using the Admin command prompt? Right mouse on the start button, select Command Prompt (Admin)

0 Kudos
AngelaBozeman
New Contributor III

I did try running the command line as an administrator with the same result. I'm wondering if I need to run command line in compatibility mode...

0 Kudos
FredSpataro
Occasional Contributor III

Hi Angela:

I'm running ArcGIS Desktop 10.3.1 on Windows 10.0.10586 (this is the November 2015 stable build i believe).  I don't have any trouble running ArcGIS or ArcPY or need to do anything special ie compatibility mode for either.

Do you get the same result with both the 32bit and 64bit version of python? 

C:\>c:\Python27\ArcGISx6410.3\python.exe

C:\>c:\Python27\ArcGIS10.3\python.exe

It does seem like something is a little off with the whole install.  I'd probably uninstall ArcGIS Desktop, verify everything is removed from the "c:\Program Files (x86)\ArcGIS\Desktop10.3" folder and remove/delete the entire python C:\Python27 directory... just to make sure something older artifact is not lingering.  Then reinstall ArcGIS Dekstop.