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.

cannot import name 'imperials' from 'astropy.units'

See original GitHub issue

Description

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'

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

github_iconTop GitHub Comments

1reaction
pllimcommented, Jul 27, 2021

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.

1reaction
astrofrogcommented, Jul 27, 2021

I’m running into the same issue with PyWWT using u.imperial:

In [1]: from astropy import units as u

In [2]: u.imperial
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-f25c0008b10d> in <module>
----> 1 u.imperial

AttributeError: module 'astropy.units' has no attribute 'imperial'
Read more comments on GitHub >

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

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