Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'typing_extensions' has no attribute 'OrderedDictTypedDict' #12551

Closed
redeaglekr opened this issue Dec 2, 2021 · 9 comments · Fixed by #12812
Closed

Comments

@redeaglekr
Copy link

redeaglekr commented Dec 2, 2021

Hi,
I was using astropy wcs while working with my images. I have been using this code for more than one month and this is the first time I am getting this error. I uninstalled astropy and then re installed v5.0. but the error doesn't go away.

from astropy.wcs import WCS
w = WCS(hdu[1].header)

the error is :

Traceback (most recent call last):
  File "/home/XXXXXXs/.local/lib/python3.8/site-packages/astropy/units/_typing.py", line 9, in <module>
    from typing import Annotated
ImportError: cannot import name 'Annotated' from 'typing' (/usr/lib/python3.8/typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode
    exec(code, self.locals)
  File "/home/XXXXXXX/photometry/XXXXX/photometryopener.py", line 3, in <module>
    from astropy.wcs import WCS
  File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/wcs/__init__.py", line 26, in <module>
    from .wcs import *
  File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/wcs/wcs.py", line 50, in <module>
    from astropy import units as u
  File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/__init__.py", line 40, in <module>
    from .decorators import *
  File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/decorators.py", line 13, in <module>
    from . import _typing as T
  File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/_typing.py", line 18, in <module>
    from typing_extensions import *  # override typing
AttributeError: module 'typing_extensions' has no attribute 'OrderedDictTypedDict'
@redeaglekr redeaglekr added the Bug label Dec 2, 2021
@github-actions
Copy link

github-actions bot commented Dec 2, 2021

Welcome to Astropy 👋 and thank you for your first issue!

A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details.

GitHub issues in the Astropy repository are used to track bug reports and feature requests; If your issue poses a question about how to use Astropy, please instead raise your question in the Astropy Discourse user forum and close this issue.

If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org.

@pllim pllim added the units label Dec 2, 2021
@pllim
Copy link
Member

pllim commented Dec 2, 2021

@nstarman added that typing module in #10662 , so hopefully he can advise.

Might also be helpful if you let us know what is this WCS by printing out w.

@redeaglekr
Copy link
Author

redeaglekr commented Dec 2, 2021

Hi,

I tried to print "w", but nothing is printed out and same error is repeated. I guess it's from the import.

@pllim
Copy link
Member

pllim commented Dec 2, 2021

Ah, right, because the error happened in the WCS call. My bad. Please do this:

print(hdu[1].header)

@redeaglekr
Copy link
Author

Hi,

No change!!!

Traceback (most recent call last):
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 1157, in _try_while_unread_hdus
return func(*args, **kwargs)
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/units/_typing.py", line 9, in
from typing import Annotated
ImportError: cannot import name 'Annotated' from 'typing' (/usr/lib/python3.8/typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode
exec(code, self.locals)
File "/home/XXXXXXX/photometry/XXXXXX/photometryopener.py", line 61, in
fc(dirname1)
File "/home/XXXXXXX/photometry/XXXXXX/photometryopener.py", line 19, in fc
ecflux = hdu[2].data["flux"]
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 322, in getitem
return self._try_while_unread_hdus(super().getitem,
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 1159, in _try_while_unread_hdus
if self._read_next_hdu():
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 1200, in _read_next_hdu
hdu = _BaseHDU.readfrom(fileobj, **kwargs)
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/base.py", line 332, in readfrom
hdu = cls._readfrom_internal(fileobj, checksum=checksum,
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/base.py", line 475, in _readfrom_internal
hdu = cls(data=DELAYED, header=header, **new_kwargs)
File "/home/XXXXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/compressed.py", line 618, in init
super().init(data=data, header=header)
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/io/fits/hdu/table.py", line 855, in init
from astropy.table import Table
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/table/init.py", line 4, in
from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo
File "/home/XXXXXXX/.local/lib/python3.8/site-packages/astropy/table/column.py", line 12, in
from astropy.units import Unit, Quantity
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/init.py", line 40, in
from .decorators import *
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/decorators.py", line 13, in
from . import _typing as T
File "/home/XXXXXX/.local/lib/python3.8/site-packages/astropy/units/_typing.py", line 18, in
from typing_extensions import * # override typing
AttributeError: module 'typing_extensions' has no attribute 'OrderedDictTypedDict'

@saimn
Copy link
Contributor

saimn commented Dec 2, 2021

It seems there is an issue with your typing_extensions installation. Which version do you have ? You could try to uninstall and reinstall it.

@redeaglekr
Copy link
Author

redeaglekr commented Dec 2, 2021

Solved! Thanks. uninstall version 3.10 and installed 4.0.1

@pllim pllim added question and removed Bug labels Dec 2, 2021
@nstarman
Copy link
Member

nstarman commented Dec 2, 2021

Maybe I/we should set a minimum version for typing_extensions...

@lpsinger
Copy link
Contributor

lpsinger commented Feb 3, 2022

This was closed, but I think that the bug remains: there needs to be a minimum version set for typing_extensions.

lpsinger added a commit to lpsinger/astropy that referenced this issue Feb 3, 2022
Astropy requires typing_extensions>=3.10.0.1. This is the earliest
version that does not trigger the error reported in astropy#12551.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants