question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PermissionError WinError32 using CCDData.read on Windows 10

See original GitHub issue

Specs: 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:closed
  • Created 5 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
saimncommented, Aug 23, 2018

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 using ccd = CCDData.read(filename, numhdu=0, format='fits') goes directly into fits.open which use the cache by default.

2reactions
pllimcommented, Aug 24, 2018

Wait, just to clarify… Are you saying that if I use format='fits', then I don’t need to set memmap=False? (I guess there is one way to find out…)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found