cannot import name 'imperials' from 'astropy.units'
See original GitHub issueDescription
Our spectroscopy package radis depends on Astropy.units. Latest build fetched astropy==4.3 and failed with the following error :
AttributeError: module 'astropy.units' has no attribute 'imperial'
- I could find a similar error encountered by @pllim in https://github.com/astropy/astropy/pull/11204#issuecomment-821844588, which helped a lot to yield a fix, below.
- I trace the error to the change of Imports in #11592 by @namurphy :
Expected behavior
Original code worked :
import astropy.units as u
u.K in (u.K, u.imperial.deg_F)
>>> cannot import name 'imperials' from 'astropy.units'
Now I have to update the code to
import astropy.units as u
from astropy.units.imperial import deg_F
u.K in (u.K, deg_F)
>>> True
If this is the expected behavior (and cleaner way to import), this Issue can be closed right away. Hopefully the title will help people that would encounter the same proper to find an easy fix.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Units and Quantities (astropy.units) — Astropy v5.2
An equivalency for converting linear flux units (“maggys”) defined relative to a standard source into a standardized system. astropy.units.imperial Module¶.
Read more >Astropy cannot parse inches - python - Stack Overflow
I got message: {ValueError}'inch' did not parse as unit: At col 0, inch is not a valid unit. I have check documentation and...
Read more >Units and Quantities (astropy.units) — Astropy v1.0.4
Enable Imperial units so they appear in results of find_equivalent_units and compose. astropy.units.cds Module¶. This package defines units used in the CDS ...
Read more >astropy/core.py at main - units - GitHub
"Filter the set of units to avoid name clashes before ". "enabling them." ... from astropy.units import imperial ... "Can not get names...
Read more >Units and Quantities (astropy.units) — Astropy v1.2.dev14793
from astropy.units import imperial >>> cms = u.cm / u.s >>> # ...and then use ... This module defines the Quantity object, which...
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
FYI to packages affected by this: Going forward, we highly recommend adding a CI job to test against astropy dev, or at the very least test the release candidate when it is announced.
I’m running into the same issue with PyWWT using
u.imperial
: