temp-account10 / maps4mac

Automatically exported from code.google.com/p/maps4mac
0 stars 0 forks source link

AttributeError on OSX #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run osm2spatialite

What is the expected output? What do you see instead?

Expected: normal program flow
Actual:
Traceback (most recent call last):
  File "./osm2spatialite.py", line 753, in <module>
    main()
  File "./osm2spatialite.py", line 746, in main
    db = trydb(dbfilename, force)
  File "./osm2spatialite.py", line 664, in trydb
    db.enable_load_extension(True)
AttributeError: 'pysqlite2.dbapi2.Connection' object has no attribute 
'enable_load_extension'

What version of the product are you using? On what operating system?
osm2spatialite0.3 on osx 10.6

Please provide any additional information below.

error is on line 664:  db.enable_load_extension(True) which doesn't seem to be 
supported on osx out of the box. This isn't nessecary here, since extensions 
are only loaded when platform is linux or windows.
I moved the declaration into the try statements and now it works for me.

    error = ""
    if platform.system() == 'Linux':
        try:
            db.enable_load_extension(True)
            db.load_extension("libspatialite.so")
        except:
            pass    
        error = "ERROR: Cannot find libspatialite.so in path."
    elif platform.system() == 'Windows':
        try:
            db.enable_load_extension(True)
            db.load_extension("libspatialite-2.dll")
        except:
            pass
        error = "ERROR: Cannot find libspatialite-2.dll in path."

Attached is the file which includes my fix

Original issue reported on code.google.com by er...@evrobv.nl on 17 Apr 2012 at 7:24

Attachments:

GoogleCodeExporter commented 8 years ago
Turns out on osx some extension needs to be loaded, so the full if elif 
statment becomes:

    if platform.system() == 'Linux':
        try:
            db.enable_load_extension(True)
            db.load_extension("libspatialite.so")
        except:
            pass    
        error = "ERROR: Cannot find libspatialite.so in path."
    elif platform.system() == 'Windows':
        try:
            db.enable_load_extension(True)
            db.load_extension("libspatialite-2.dll")
        except:
            pass
        error = "ERROR: Cannot find libspatialite-2.dll in path."
    elif platform.system() == 'Darwin':
        try:
            cur = db.cursor()
            cur.execute("SELECT load_extension(\"libspatialite.dylib\")")
        except:
            pass
        error = "ERROR: Cannot load libspatialite.dylib in path."

new file with my fix attached.

Original comment by er...@evrobv.nl on 17 Apr 2012 at 7:50

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by DanielS...@gmail.com on 23 Apr 2012 at 3:43