GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.1k stars 260 forks source link

WindowsError: The process cannot access the file because it is being used by another process #121

Closed megies closed 6 years ago

megies commented 7 years ago

In appveyor, I'm having trouble deleting .dbf files that were written by a shapefile.Writer and subsequently read again by a shapefile.Reader (to check contents were written correctly). I'm getting the following error: WindowsError: [Error 32] The process cannot access the file because it is being used by another process: u'c:\\users\\appveyor\\appdata\\local\\temp\\1\\obspy-ogjwjz\\inventory.dbf' on a os.remove(filename) call: See https://ci.appveyor.com/project/obspy/obspy/build/1.0.5339-master/job/ox2tu1p3xry0kkx4#L573

I suspect the Reader is likely to blame, but even a manual reader_instance.close() call did not make this error go away.

Have you seen something like the above before?

See obspy/obspy#1933.

GeospatialPython commented 7 years ago

Try:

reader_instance = None

megies commented 7 years ago

This is fixed in #122 , see https://github.com/GeospatialPython/pyshp/pull/122/files#diff-a46dda5a6b10b8e346e3901f25ede20dL386.