Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in spatial.to_featurelayer: Temp zip file being used by another process #2054

Open
roelofsaj opened this issue Sep 18, 2024 · 0 comments
Labels

Comments

@roelofsaj
Copy link

Describe the bug
When using spatial.to_featurelayer on a moderately large (62,000 rows, 93 columns) spatially enabled data frame, I'm getting the following error, and the feature layer is never created.

C:\Users\aheinlei\work\mi-flora-scripting\to_featurelayer_bug_demo.py:9: DtypeWarning: Columns (16,17,19,20,21,22,23,26,30,31,32,52,54,57,61) have mixed types. Specify dtype option on import or set low_memory=False.
  df = pd.read_csv('demo_data_62k.csv')
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\pydevd.py", line 1534, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Users\aheinlei\work\mi-flora-scripting\to_featurelayer_bug_demo.py", line 109, in <module>
    fl = spatial_df.spatial.to_featurelayer(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\aheinlei\AppData\Local\ESRI\conda\envs\miflora_3_3_1\Lib\site-packages\arcgis\features\geo\_accessor.py", line 2912, in to_featurelayer
    result = content.import_data(
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\aheinlei\AppData\Local\ESRI\conda\envs\miflora_3_3_1\Lib\site-packages\arcgis\gis\__init__.py", line 8591, in import_data
    return _cm_helper.import_as_item(self._gis, df, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\aheinlei\AppData\Local\ESRI\conda\envs\miflora_3_3_1\Lib\site-packages\arcgis\gis\_impl\_content_manager\_import_data.py", line 247, in import_as_item
    file_item, new_item = _create_file_item(gis, df, file_type, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\aheinlei\AppData\Local\ESRI\conda\envs\miflora_3_3_1\Lib\site-packages\arcgis\gis\_impl\_content_manager\_import_data.py", line 156, in _create_file_item
    os.remove(file)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\aheinlei\\AppData\\Local\\Temp\\a694de98\\a86051.zip'
python-BaseException

To Reproduce
Run the python script atteched below (file extension changed to .txt to allow uploading). I'd rather not post the data file here publicly, so if someone from ESRI takes a look at this, feel free to contact me and I'll email it. I've tried making a dummy file to post here instead of the actual one, but nothing I've generated so far has been able to cause this error. Also note that the file originally had 220k+ lines; I'm able to reduce the error with a subset of this file that's 62k lines or more, but once I start making files smaller than that, the error doesn't occur. This is independent of which portion of the records I use to create the smaller files.
to_featurelayer_bug_demo.txt

Expected behavior
I expect to_featurelayer() to create my feature layer without throwing an error.

Platform (please complete the following information):

  • OS: Windows
  • Python API Version 2.3.1

Additional context
This error started occurring after Python API version 2.0.1. (Until I recently upgraded to ArcGIS Pro 3.3.1, I was specifically installing Python API version 2.0.1 instead of more recent versions because it would successfully run my script without throwing this error.)

@roelofsaj roelofsaj added the bug label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant