PermissionError WinError32 using CCDData.read on Windows 10
See original GitHub issueSpecs: Astropy 3.0.4, Numpy 1.15.0, Python 3.6.6, conda
, Git Bash, Windows 10, MSC v.1900 64 bit (AMD64)
from astropy.nddata import CCDData
filename = 'https://astropy.stsci.edu/data/photometry/spitzer_example_image.fits'
ccd = CCDData.read(filename, numhdu=0)
Downloading https://astropy.stsci.edu/data/photometry/spitzer_example_image.fits
|===========================================| 2.1M/2.1M (100.00%) 2s
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
~\Miniconda3\envs\py36\lib\site-packages\astropy\nddata\mixins\ndio.py in read(c
ls, *args, **kwargs)
25 formats.
26 """
---> 27 return io_registry.read(cls, *args, **kwargs)
28
29 def write(self, *args, **kwargs):
~\Miniconda3\envs\py36\lib\site-packages\astropy\io\registry.py in read(cls, for
mat, *args, **kwargs)
528 finally:
529 if ctx is not None:
--> 530 ctx.__exit__(*sys.exc_info())
531
532 return data
~\Miniconda3\envs\py36\lib\contextlib.py in __exit__(self, type, value, tracebac
k)
86 if type is None:
87 try:
---> 88 next(self.gen)
89 except StopIteration:
90 return False
~\Miniconda3\envs\py36\lib\site-packages\astropy\utils\data.py in get_readable_f
ileobj(name_or_obj, encoding, cache, show_progress, remote_timeout)
316 fd.close()
317 for fd in delete_fds:
--> 318 os.remove(fd.name)
319
320
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'C:\\Users\\username\\AppData\\Local\\Temp\\tmp9j3hqa1c'
The weird thing is that I cannot reproduce when calling get_readable_fileobj
nor fits.open
directly.
@MSeifert04 , since you use Windows too, have you encountered this? Anyone?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
[WinError 32] The process cannot access the file because it is ...
This is basically permission error, you just need to close the file before removing it. After getting the image size ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh that’s because the
io.registry
downloads the file when it doesn’t know the format, and doesn’t use the cache by default. So usingccd = CCDData.read(filename, numhdu=0, format='fits')
goes directly intofits.open
which use the cache by default.Wait, just to clarify… Are you saying that if I use
format='fits'
, then I don’t need to setmemmap=False
? (I guess there is one way to find out…)