You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue happens because shutil.copyfile() attempts to open tempfile which is already opened. On Windows platform this raises Permission Error.
Here's how I could solve that in slconfig.py (lines 80-83):
80 with tempfile.TemporaryDirectory() as temp_config_dir:
81 temp_config_file = tempfile.NamedTemporaryFile(dir=temp_config_dir, suffix=".py") # here temp_config_file is opened
82 temp_config_name = osp.basename(temp_config_file.name)
# on Windows attempt to open temp_config_file by shutil raises IOError: [Errno 13] Permission denied:
# close file before using shutil
temp_config_file.close()
83 shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name))
Are you willing to submit a PR?
Yes I'd like to help by submitting a PR!
The text was updated successfully, but these errors were encountered:
👋 Hello @Roman-Rudensky, thank you for leaving an issue on Roboflow Notebooks.
🐞 Bug reports
If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.
If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.
💬 Get in touch
Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.
To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.
The bug is caused by different implement of tempfile between linux and windows.
The file is already opened but shutil.copyfile() will try to open it again causing the permission error -- the file is already locked.
So you should use delete=False when using NamedTemporaryFile near slconfig.py:86, and mannually close the tempfile near the code 'tempfile.close()' with os.unlink(...).
ref: https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file
Search before asking
Notebook name
zero-shot-object-detection-with-grounding-dino.ipynb
Bug
Environment
Minimal Reproducible Example
No response
Additional
The issue happens because shutil.copyfile() attempts to open tempfile which is already opened. On Windows platform this raises Permission Error.
Here's how I could solve that in slconfig.py (lines 80-83):
80 with tempfile.TemporaryDirectory() as temp_config_dir:
81 temp_config_file = tempfile.NamedTemporaryFile(dir=temp_config_dir, suffix=".py") # here temp_config_file is opened
82 temp_config_name = osp.basename(temp_config_file.name)
# on Windows attempt to open temp_config_file by shutil raises IOError: [Errno 13] Permission denied:
# close file before using shutil
temp_config_file.close()
83 shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name))
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: