[GIS] ArcPy not running on standard console

arcgis-10.0arcpyinstallation

I know this is a newbie ArcPy question, but here is the deal:

While I'm inside ArcMap 10, the Python window gives me all output correctly, like this:

>>> arcpy.env.workspace = r"C:\uber.gdb"
>>> arcpy.ListDatasets("*","ALL")
[u'uberlandia_urbano', u'Idw_pop2006', u'Idw_pop2000']

But, if I open cmd window (Run > cmd) and type the exact same commands, it will give me an empty list as a result.

I'm pretty sure that the Python version used is the one tied up with arcgis, since I can import arcpy.

Any chance that arcpy does not work on the standard python console?

Best Answer

It should totally run at a Windows command prompt. Sounds like all is well with the install, since you can import arcpy. Make sure that your PATH environmental variable is properly set to the ArcGIS Python install directory, just to be sure. The following from a command prompt on my box:

C:\>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
>>> import os
>>> os.environ['PATH'].split(os.pathsep)
['C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common', 'C:\\Windows\\sys
tem32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\Wi
ndowsPowerShell\\v1.0\\', 'C:\\Program Files\\Intel\\DMIX', 'c:\\Program Files (
x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\', 'c:\\Program Files\\Microsoft S
QL Server\\100\\Tools\\Binn\\', 'c:\\Program Files\\Microsoft SQL Server\\100\\D
TS\\Binn\\', 'c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\V
SShell\\Common7\\IDE\\', 'c:\\Program Files (x86)\\Microsoft SQL Server\\100\\DT
S\\Binn\\', 'C:\\Program Files\\ArcGIS\\ArcSDE\\sqlexe\\bin', 'C:\\Program Files
 (x86)\\GnuWin32\\bin', 'C:\\Program Files\\TortoiseGit\\bin', 'C:\\Cygwin\\lib\
\git-core', 'C:\\Program Files (x86)\\Git\\cmd', 'C:\\Program Files (x86)\\GDAL'
, 'C:\\Python26\\ArcGIS10.0\\Lib\\site-packages\\', 'C:\\Python26\\ArcGIS10.0',
'C:\\Python26\\ArcGIS10.0\\Scripts', 'C:\\Program Files (x86)\\FME2011\\', 'C:\\
Program Files\\TortoiseHg', 'C:\\Program Files (x86)\\GIMP-2.0\\bin', '"C:\\Prog
ram Files\\e-on software\\Vue 9.5 Infinite"', 'C:\\Program Files\\Curl', 'C:\\Mi
nGW\\bin']
>>>

Note the paths C:\\Python26\\ArcGIS10.0 and C:\\Python26\\ArcGIS10.0\\Scripts...these are the standard ArcGIS Python install directories.

So you are running the exact same code at the Windows command line as you are inside of ArcMap?

EDIT:

Just tried your exact code on one of my file geodatabases at the Windows command line (same instance that I used above to test my PATH):

>>> arcpy.env.workspace = r"D:\Projects\GDBs\slowbutter.gdb"
>>> arcpy.ListDatasets("*", "ALL")
[u'IPAS', u'VIESORE_UK', u'VIESORE_NC', u'NHD', u'USA', u'World', u'NCLiDAR2007'
, u'NCNEDOneNinth', u'IPASHsp100mDEM', u'NCNAIP2005']
>>>

Where the first six items are feature datasets and the rest are rasters.