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

Using "-w" option gives error: NameError: name 'Any' is not defined #2992

Closed
loopy321 opened this issue Oct 26, 2024 · 3 comments
Closed

Using "-w" option gives error: NameError: name 'Any' is not defined #2992

loopy321 opened this issue Oct 26, 2024 · 3 comments
Labels
Milestone

Comments

@loopy321
Copy link

Check the bug

Describe the bug

glances -w
Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/glances", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/__init__.py", line 173, in main
    start(config=core.get_config(), args=core.get_args())
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/__init__.py", line 98, in start
    from glances.webserver import GlancesWebServer as GlancesMode
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/webserver.py", line 12, in <module>
    from glances.outputs.glances_restful_api import GlancesRestfulApi
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/outputs/glances_restful_api.py", line 59, in <module>
    class GlancesJSONResponse(JSONResponse):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/outputs/glances_restful_api.py", line 66, in GlancesJSONResponse
    def render(self, content: Any) -> bytes:
NameError: name 'Any' is not defined
python3 --version
Python 3.8.10
glances --version
Glances version:	4.2.0
Glances API version:	4
PsUtil version:		6.1.0
Log file:		/home/ubuntu/.local/share/glances/glances.log
cat /home/ubuntu/.local/share/glances/glances.log

024-10-26 13:54:01,822 -- INFO -- Start Glances 4.2.0
2024-10-26 13:54:01,822 -- INFO -- CPython 3.8.10 (/usr/bin/python3) and psutil 6.1.0 detected
2024-10-26 13:54:02,157 -- INFO -- Start GlancesStandalone mode
2024-10-26 13:54:02,670 -- CRITICAL -- Error while initializing the containers plugin ('type' object is not subscriptable)
2024-10-26 13:54:02,671 -- ERROR -- Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/stats.py", line 100, in _load_plugin
    plugin = import_module('glances.plugins.' + plugin_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/plugins/containers/__init__.py", line 19, in <module>
    from glances.plugins.containers.engines.podman import PodmanExtension, import_podman_error_tag
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/plugins/containers/engines/podman.py", line 246, in <module>
    class PodmanExtension:
  File "/home/ubuntu/.local/lib/python3.8/site-packages/glances/plugins/containers/engines/podman.py", line 286, in PodmanExtension
    def update(self, all_tag) -> Tuple[Dict, list[Dict[str, Any]]]:
TypeError: 'type' object is not subscriptable

2024-10-26 13:54:03,097 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 41, 'SYN_SENT': 4, 'SYN_RECV': 1, 'initiated': 5, 'terminated': 5, 'nf_conntrack_count': 585.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.89263916015625}
2024-10-26 13:54:05,312 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 5, 'SYN_RECV': 0, 'initiated': 5, 'terminated': 5, 'nf_conntrack_count': 594.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.9063720703125}
2024-10-26 13:54:07,257 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 2, 'SYN_RECV': 0, 'initiated': 2, 'terminated': 2, 'nf_conntrack_count': 599.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.91400146484375}
2024-10-26 13:54:09,430 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 43, 'SYN_SENT': 2, 'SYN_RECV': 0, 'initiated': 2, 'terminated': 2, 'nf_conntrack_count': 606.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.9246826171875}
2024-10-26 13:54:11,544 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 43, 'SYN_SENT': 3, 'SYN_RECV': 1, 'initiated': 4, 'terminated': 4, 'nf_conntrack_count': 615.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.93841552734375}
2024-10-26 13:54:13,642 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 43, 'SYN_SENT': 3, 'SYN_RECV': 0, 'initiated': 3, 'terminated': 3, 'nf_conntrack_count': 617.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.94146728515625}
2024-10-26 13:54:15,763 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 3, 'SYN_RECV': 0, 'initiated': 3, 'terminated': 3, 'nf_conntrack_count': 621.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.94757080078125}
2024-10-26 13:54:17,878 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 3, 'SYN_RECV': 0, 'initiated': 3, 'terminated': 3, 'nf_conntrack_count': 624.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.9521484375}
2024-10-26 13:54:19,970 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 3, 'SYN_RECV': 0, 'initiated': 3, 'terminated': 3, 'nf_conntrack_count': 625.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.95367431640625}
2024-10-26 13:54:21,957 -- INFO -- {'net_connections_enabled': True, 'nf_conntrack_enabled': True, 'LISTEN': 30, 'ESTABLISHED': 42, 'SYN_SENT': 4, 'SYN_RECV': 1, 'initiated': 5, 'terminated': 5, 'nf_conntrack_count': 630.0, 'nf_conntrack_max': 65536.0, 'nf_conntrack_percent': 0.9613037109375}
2024-10-26 13:54:22,393 -- INFO -- Stop Glances (keypressed: 113)

To Reproduce
Steps to reproduce the behavior:

  1. Start Glances with the following options '-w'
  2. See error

Expected behavior
glances works fine without -w

Screenshots

Environement (please complete the following information)

  • Operating System: Ubuntu 20.04 LTS
  • How do you install Glances: pip install glances[all]

Additional context
glances works as expected with pyenv using python version 3.12

@nicolargo nicolargo added the bug label Oct 30, 2024
@nicolargo
Copy link
Owner

nicolargo commented Oct 30, 2024

It's look like the -w option is no more compatible with Python<=3.8.

I will have a look, thanks for the head up @loopy321 !

https://stackoverflow.com/questions/65120501/typing-any-in-python-3-9-and-pep-585-type-hinting-generics-in-standard-collect#comment115967776_65121341

@nicolargo nicolargo added this to the Glances 4.3.0 milestone Oct 30, 2024
@nicolargo
Copy link
Owner

@RazCrimson Please can you have a look on this issue ?

@RazCrimson
Copy link
Collaborator

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants