astropy: UnicodeEncodeError using astropy.units.cds
The following two scripts fail for me at the Python 2.7.12 command line using AstroPy 1.2.1:
import astropy.units.cds
help(astropy.units.cds)
and
import astropy.coordinates
import astropy.units.cds
astropy.units.cds.enable()
astropy.coordinates.Angle("5d")
The former fails with:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site.py", line 464, in __call__
return pydoc.help(*args, **kwds)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 1794, in __call__
self.help(request)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 1841, in help
else: doc(request, 'Help on %s:')
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 1578, in doc
pager(render_doc(thing, title, forceload))
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 1573, in render_doc
return title % desc + '\n\n' + text.document(object, name)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 361, in document
if inspect.ismodule(object): return self.docmodule(*args)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/pydoc.py", line 1094, in docmodule
for key, value in inspect.getmembers(object, inspect.isclass):
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/inspect.py", line 253, in getmembers
value = getattr(object, key)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 2: ordinal not in range(128)
and the latter fails with:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/coordinates/angles.py", line 111, in __new__
angle, new_unit = util.parse_angle(angle, unit)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/coordinates/angle_utilities.py", line 348, in parse_angle
return _AngleParser().parse(angle, unit, debug=debug)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/coordinates/angle_utilities.py", line 44, in __init__
_AngleParser._parser, _AngleParser._lexer = self._make_parser()
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/coordinates/angle_utilities.py", line 104, in _make_parser
'(?:{0})'.format(x) for x in cls._get_simple_unit_names())
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/coordinates/angle_utilities.py", line 49, in _get_simple_unit_names
u.radian.find_equivalent_units(include_prefix_units=True))
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/units/core.py", line 1438, in find_equivalent_units
include_prefix_units=include_prefix_units)
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/units/core.py", line 1263, in compose
max_depth=max_depth, depth=0, cached_results={}))
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/units/core.py", line 1255, in sort_results
if str(result) != str(last_result):
File "/Users/rowen/UW/LSST/lsstsw/miniconda/lib/python2.7/site-packages/astropy/units/core.py", line 504, in __bytes__
return unit_format.Generic.to_string(self).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb5' in position 12: ordinal not in range(128)
See also https://groups.google.com/forum/#!topic/astropy-dev/-ebCdowI_0M
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (23 by maintainers)
@r-owen - it is the problem in python3 noted in https://github.com/astropy/astropy/issues/5350#issuecomment-248770151