Select to view content in your preferred language

ListWorkspaces command different for 10.1???

817
8
Jump to solution
01-28-2013 05:34 AM
maxsteinbrenner
Emerging Contributor
so i have been having problems accessing tables in an mdb using arcpy on our server running arcgis10.1.

i think i have figured out part of the problem.

running this script:

import arcpy  arcpy.env.workspace = "\\\\STSHURON\\data\\gis_work\\data_maint\\Monthly_Update\\" wrkspc = arcpy.ListWorkspaces()  for workspace in wrkspc:     print workspace


running the identical script (above) our 10.1 machine lists none of the mdb files in the directory as workspaces. on our 10.0 box all the mdb's in the directory are listed. all the other files that could be listed as workspaces in the directory (other directories, excel files, etc.) are listed when the script is run on either box; the only difference seems to be the access databases don't show up with the script on the 10.1 box. any ideas as to why that is?

thanks!

max
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
so i have been having problems accessing tables in an mdb using arcpy on our server running arcgis10.1.

i think i have figured out part of the problem.

running this script:

import arcpy  arcpy.env.workspace = "\\\\STSHURON\\data\\gis_work\\data_maint\\Monthly_Update\\" wrkspc = arcpy.ListWorkspaces()  for workspace in wrkspc:     print workspace


running the identical script (above) our 10.1 machine lists none of the mdb files in the directory as workspaces. on our 10.0 box all the mdb's in the directory are listed. all the other files that could be listed as workspaces in the directory (other directories, excel files, etc.) are listed when the script is run on either box; the only difference seems to be the access databases don't show up with the script on the 10.1 box. any ideas as to why that is?

thanks!

max


Have you installed the 64 bit background processing for your 10.1 version?  This is not compatible with personal geodatabases.  In this case you have to use the 32 bit python.  The 64 bit will not list the personal gdb's.  Here's an example:

import arcpy, sys  arcpy.env.workspace =  r'G:\Data\Geodatabase\Archive'  print "Running against: {0}\n".format(sys.version) for ws in arcpy.ListWorkspaces():     print ws

here are the results when ran from 32 bit:
>>> ================================ RESTART ================================ >>>  Running against: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]  G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.mdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2014.mdb >>> 


And here is the exact same script ran on 64 bit:
>>>  Running against: 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]  G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb >>> 

As you can see it only listed the 2 file gdb's and not the personal gdb's when ran with 64 bit python.

View solution in original post

0 Kudos
8 Replies
by Anonymous User
Not applicable
so i have been having problems accessing tables in an mdb using arcpy on our server running arcgis10.1.

i think i have figured out part of the problem.

running this script:

import arcpy  arcpy.env.workspace = "\\\\STSHURON\\data\\gis_work\\data_maint\\Monthly_Update\\" wrkspc = arcpy.ListWorkspaces()  for workspace in wrkspc:     print workspace


running the identical script (above) our 10.1 machine lists none of the mdb files in the directory as workspaces. on our 10.0 box all the mdb's in the directory are listed. all the other files that could be listed as workspaces in the directory (other directories, excel files, etc.) are listed when the script is run on either box; the only difference seems to be the access databases don't show up with the script on the 10.1 box. any ideas as to why that is?

thanks!

max


Have you installed the 64 bit background processing for your 10.1 version?  This is not compatible with personal geodatabases.  In this case you have to use the 32 bit python.  The 64 bit will not list the personal gdb's.  Here's an example:

import arcpy, sys  arcpy.env.workspace =  r'G:\Data\Geodatabase\Archive'  print "Running against: {0}\n".format(sys.version) for ws in arcpy.ListWorkspaces():     print ws

here are the results when ran from 32 bit:
>>> ================================ RESTART ================================ >>>  Running against: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]  G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.mdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2014.mdb >>> 


And here is the exact same script ran on 64 bit:
>>>  Running against: 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]  G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb >>> 

As you can see it only listed the 2 file gdb's and not the personal gdb's when ran with 64 bit python.
0 Kudos
maxsteinbrenner
Emerging Contributor
Have you installed the 64 bit background processing for your 10.1 version?  This is not compatible with personal geodatabases.  In this case you have to use the 32 bit python.  The 64 bit will not list the personal gdb's.  Here's an example:

import arcpy, sys

arcpy.env.workspace =  r'G:\Data\Geodatabase\Archive'

print "Running against: {0}\n".format(sys.version)
for ws in arcpy.ListWorkspaces():
    print ws

here are the results when ran from 32 bit:
>>> ================================ RESTART ================================
>>> 
Running against: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb
G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.mdb
G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb
G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2014.mdb
>>> 


And here is the exact same script ran on 64 bit:
>>> 
Running against: 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]

G:\Data\Geodatabase\Archive\Cedar_County_Switched_1_23_2013.gdb
G:\Data\Geodatabase\Archive\Cedar_Switched_1_23_2013.gdb
>>> 

As you can see it only listed the 2 file gdb's and not the personal gdb's when ran with 64 bit python.


that is exactly my problem i think. the new box is 64 bit....

so is there a way around this? you have to be able to talk to access personal geodatabases somehow with the 64 bit version somehow still hopefully???

thanks,

max
0 Kudos
by Anonymous User
Not applicable
Yes there are a couple ways around it.  What I have been doing is force it to run 32 bit by just creating a simple batch file.  Just open up notepad (save it with a ".bat" extension) and type the following (except replace the script name and location):

start C:\Python27\ArcGIS10.1\python.exe G:\Misc\Scripts\UNMPD_PARCELS.py

I think the above is the easiest.  It will run in a command prompt environment so if you want to see the results after it is finished you may want to add the "raw_input()" line at the end of your script so it will stay open until you hit ENTER.

OR if you want to open in in the regular python shell the other option is to open up the 32 bit python.exe in the normal ArcGIS 10.1 folder (I created shortcuts for both 32 bit and 64 bit to my desktop) and once you are in there you can manually open your script with File > Open.

Also, since ArcMap and ArcCatalog are both 32 bit, you could run your script in they pythonwin inside one of those applications because it will use the 32 bit python by default.
0 Kudos
maxsteinbrenner
Emerging Contributor
OR if you want to open in in the regular python shell the other option is to open up the 32 bit python.exe in the normal ArcGIS 10.1 folder (I created shortcuts for both 32 bit and 64 bit to my desktop) and once you are in there you can manually open your script with File > Open.


thanks for all the info so far!

sorry if this is a dumb question but here goes (i am not so well versed in python lingo). when you mention the python shell your referring to idle correct? if so, i use pythonwin instead because that is just what i was taught on and am used to using. would installing the 32bit version of pythonwin(to run along with the 64bit version) on the 10.1 box work for scripts like this?
0 Kudos
by Anonymous User
Not applicable
I believe so.  Using the 32 bit PythonWin is a good idea, may be the easiest way to handle scripts that use personal gdb's.  That way you can avoid the confusion about which version of IDLE you are using.
0 Kudos
maxsteinbrenner
Emerging Contributor
I believe so.  Using the 32 bit PythonWin is a good idea, may be the easiest way to handle scripts that use personal gdb's.  That way you can avoid the confusion about which version of IDLE you are using.


success!!!! thanks to your help.

installed a 32bit version and 64bit version of pythoinwin on the same box and this script works just like it did in 10.0 on the 32bit version.

problem solved; BUT i have a final question for anyone who has the time...

what is better about the 64bit version (IE: why not just uninstall the 64bit version and run everything in the 32bit version of pythonwin to avoid confusion)?
0 Kudos
by Anonymous User
Not applicable

what is better about the 64bit version (IE: why not just uninstall the 64bit version and run everything in the 32bit version of pythonwin to avoid confusion)?


I am no expert on this subject, but I think your answer can be found in your question here.  The 64 bit option is not necessary for regular scripting operations since you can do everything in 32 bit.  However, you have twice the processing power with the 64 bit and your scripts *should* work much more efficiently.  I have noticed nice performance boost for many of my scripts when they are ran in the 64 bit environment.  This is especially true when working on very large data sets.

Here is a little more info about background 64 bit geoprocessing:

http://resources.arcgis.com/en/help/main/10.1/index.html#/Background_Geoprocessing_64_bit/0021000000...

I think you have a good idea here though to have a 32 bit version of PythonWin so you can run all the scripts that use mdb's by just manually selecting "Edit with PythonWin".  One consideration though, all your scripts may default to the 32 bit PythonWin now since that is the most recent version you installed.  Perhaps if you want maximum control you can just manually open the scripts in your prefered IDE environment or make batch files so that you can specify which version you want to run.
0 Kudos
curtvprice
MVP Esteemed Contributor
Another workaround is to turn off background processing so your script tools will run in the foreground.

As for IDLE, You have two versions of IDLE available, so you could just modify your shortcut or (set up another one) to run your script tools in 32-bit IDLE.

On my machine the shortcut is:

C:\Python27\ArcGISx6410.1\pythonw.exe "C:\Python27\ArcGISx6410.1\Lib\idlelib\idle.pyw"

this can be modified (or copy the shortcut and modify) to use:

C:\Python27\ArcGIS10.1\pythonw.exe "C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw"

Here's a blog post with more on the x64 geoprocessing:

http://blogs.esri.com/esri/arcgis/2012/10/31/announcing-64-bit-geoprocessing/
0 Kudos