AnsweredAssumed Answered

arcpy.ListTables() doesnt work in cmd but works in IDLE or arcmap python window,why?

Question asked by gauri_d on Dec 22, 2014
Latest reply on Mar 13, 2015 by richelles

Hello all,

  My python script runs well and returns all tables from mdb with arcpy.ListTables() command when i run a script in IDLE(default IDE) or python window from arcmap. But when I try to run the same script from cmd arcpy.ListTables() returns blank list []. What could be the problem?And what is the solution? As I am calling this script in my C# desktop application.

 

import xlrd
import datetime
import os
import sys
#sys.path.append("C:\Program Files\ArcGIS\Desktop10.0\arcpy")
import arcpy


#arcpy.ResetEnvironments()
arcpy.env.workspace = r"D:/Final/gdb_workspace/New Personal Geodatabase.mdb"
#Get and print a list of tables
tables = arcpy.ListTables()
print tables
for table in tables:
    print table

 

This is my simple code to list tables.I want to insert data from excel file to a particular table from this personal gdb.

When I run this script using cmd(out of arcgis environment) its not returning tables.

Is this possible to achieve and how? Or do I need to use any geoprocessing service?Any other way to achieve this?

I am able to insert data into mdb if i run the script in IDLE or python window from arcmap.

Please tell me the right way to do this task.

Outcomes