astropy.io: ImportError: No module named _bz2
See original GitHub issueHello, I am using Debian 8.7 and I got the following import error while importing fits from the astropy.io (astropy Version: 1.3.2).
from astropy.io import fits
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/io/fits/__init__.py", line 70, in <module>
from . import convenience
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/io/fits/convenience.py", line 64, in <module>
from .file import FILE_MODES, _File
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/io/fits/file.py", line 5, in <module>
import bz2
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python/bz2.py", line 20, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named _bz2
Similarly, astropy.test() gives me the following errors.
>>> astropy.test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/utils/decorators.py", line 874, in test
func = make_function_with_signature(func, name=name, **wrapped_args)
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/tests/runner.py", line 224, in test
return runner.run_tests(**kwargs)
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/tests/runner.py", line 516, in run_tests
from ..table import Table # pylint: disable=W0611
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/table/__init__.py", line 59, in <module>
from ..io.fits import connect
File "/gbdata/ScienceTools-v10r0p5-fssc-20150518-/x86_64-unknown-linux-gnu-libc2.19-10/lib/python2.7/site-packages/astropy/io/fits/__init__.py", line 16, in <module>
from . import py3compat
ImportError: cannot import name py3compat
Any help will be highly appreciated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
ImportError: No module named bz2 for Python 2.7.2
The reason of import error is while you are building python, system couldn't find the bz2 headers and skipped building bz2 module.
Read more >Source code for astropy.utils.data
One of the following: * The name of a data file included in the source distribution ... Raises ------ ImportError Given package or...
Read more >conda-forge/conda-forge.github.io - Gitter
I see, tht's not good indeed. osx is is also pretty confusing with those multiple ... in <module> from error import * ImportError:...
Read more >Full Changelog — Astropy v1.2.dev14793
If False the parameters are only copied if there is no way of saving them as ... now work if your Python interpreter...
Read more >Source code for galsim.fits
However, with recent versions of # astropy for the fits I/O, ... try: return self.bz2(file) except (ImportError, NotImplementedError): # pragma: no cover if ......
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 Free
Top 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
OK, I am preparing a PR.
Since
bz2
is an optional dependency for Python I think it makes sense to treat it as an optional dependency in astropy. Reopening the issue then, since @MSeifert04 agreed two years ago 😉