nschloe / tiptop

:desktop_computer: Command-line system monitoring
MIT License
1.77k stars 70 forks source link

[BUG] Does not work on Apple Silicon CPUs #30

Closed Rexhaif closed 3 years ago

Rexhaif commented 3 years ago

I've installed tiptop using pip in conda environment with python 3.9. However, it does not run properly and displays following traceback:

~/Downloads via ☕ v16.32 via 🐍 v3.9.7 via 🅒 ml-data took 4s
âŊ tiptop
╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────â•Ū
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/textual/widget.py:202 in _get_lines                                                               │
│                                                                                                                                                                                  │
│   199 │   def _get_lines(self) -> Lines:                                                      ╭───────── locals ─────────â•Ū                                                       │
│   200 │   │   """Get segment lines to render the widget."""                                   │ self = CPU(name='CPU#1') │                                                       │
│   201 │   │   if self.render_cache is None:                                                   ╰──────────────────────────â•Ŋ                                                       │
│ ❱ 202 │   │   │   self.render_lines()                                                                                                                                            │
│   203 │   │   assert self.render_cache is not None                                                                                                                               │
│   204 │   │   lines = self.render_cache.lines                                                                                                                                    │
│   205 │   │   return lines                                                                                                                                                       │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/textual/widget.py:188 in render_lines                                                             │
│                                                                                                                                                                                  │
│   185 │                                                                                       ╭────────── locals ──────────â•Ū                                                     │
│   186 │   def render_lines(self) -> None:                                                     │ height = 18                │                                                     │
│   187 │   │   width, height = self.size                                                       │   self = CPU(name='CPU#1') │                                                     │
│ ❱ 188 │   │   renderable = self.render_styled()                                               │  width = 180               │                                                     │
│   189 │   │   options = self.console.options.update_dimensions(width, height)                 ╰────────────────────────────â•Ŋ                                                     │
│   190 │   │   lines = self.console.render_lines(renderable, options)                                                                                                             │
│   191 │   │   self.render_cache = RenderCache(self.size, lines)                                                                                                                  │
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/textual/widget.py:128 in render_styled                                                            │
│                                                                                                                                                                                  │
│   125 │   │   Returns:                                                                        ╭───────── locals ─────────â•Ū                                                       │
│   126 │   │   │   RenderableType: A new renderable.                                           │ self = CPU(name='CPU#1') │                                                       │
│   127 │   │   """                                                                             ╰──────────────────────────â•Ŋ                                                       │
│ ❱ 128 │   │   renderable = self.render()                                                                                                                                         │
│   129 │   │   if self.padding is not None:                                                                                                                                       │
│   130 │   │   │   renderable = Padding(renderable, self.padding)                                                                                                                 │
│   131 │   │   if self.border in self.BOX_MAP:                                                                                                                                    │
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/tiptop/_cpu.py:170 in render                                                                      │
│                                                                                                                                                                                  │
│   167 │                                                                                       ╭───────── locals ─────────â•Ū                                                       │
│   168 │   def render(self):                                                                   │ self = CPU(name='CPU#1') │                                                       │
│   169 │   │   if self.is_first_render:                                                        ╰──────────────────────────â•Ŋ                                                       │
│ ❱ 170 │   │   │   self.collect_data()                                                                                                                                            │
│   171 │   │   │   self.is_first_render = False                                                                                                                                   │
│   172 │   │   return self.panel                                                                                                                                                  │
│   173                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/tiptop/_cpu.py:132 in collect_data                                                                │
│                                                                                                                                                                                  │
│   129 │   │                                                                                                                                                                      │
│   130 │   │   # load_avg = os.getloadavg()                                                                                                                                       │
│   131 │   │   # subtitle = f"Load Avg:  {load_avg[0]:.2f}  {load_avg[1]:.2f}  {load_avg[2]:.2f                                                                                   │
│ ❱ 132 │   │   subtitle = f"{round(psutil.cpu_freq().current):4d} MHz"                                                                                                            │
│   133 │   │                                                                                                                                                                      │
│   134 │   │   info_box = Panel(                                                                                                                                                  │
│   135 │   │   │   "\n".join(lines),                                                                                                                                              │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────â•Ū                                                        │
│ │ cpu_percent_colors = ['color(2)', 'color(2)', 'color(2)', 'color(2)', 'color(2)', 'color(2)', 'color(2)', 'color(2)'] │                                                        │
│ │    cpu_total_graph = '[color(4)]                                            100.0%\n                   '+290          │                                                        │
│ │    last_val_string = '100.0%'                                                                                         │                                                        │
│ │              lines = [                                                                                                │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]',                                                              │                                                        │
│ │                      │   '[color(2)]         âĒļ 100%[/]'                                                               │                                                        │
│ │                      ]                                                                                                │                                                        │
│ │             lines0 = '                                            100.0%'                                             │                                                        │
│ │          lines_cpu = [                                                                                                │                                                        │
│ │                      │   '                                            100.0%',                                        │                                                        │
│ │                      │   '                                                 âĒļ',                                        │                                                        │
│ │                      │   '                                                 âĒļ',                                        │                                                        │
│ │                      │   '                                                 âĒļ',                                        │                                                        │
│ │                      │   '                                                 âĒļ',                                        │                                                        │
│ │                      │   '                                                 âĒļ',                                        │                                                        │
│ │                      │   '                                                 âĒļ'                                         │                                                        │
│ │                      ]                                                                                                │                                                        │
│ │               load = 100.0                                                                                            │                                                        │
│ │         load_indiv = [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]                                         │                                                        │
│ │               self = CPU(name='CPU#1')                                                                                │                                                        │
│ │             stream = <tiptop.braille_stream.BrailleStream object at 0x107d83dc0>                                      │                                                        │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────â•Ŋ                                                        │
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/psutil/__init__.py:1859 in cpu_freq                                                               │
│                                                                                                                                                                                  │
│   1856 │   │   retrieval (Linux only) a list of frequencies is returned for                    ╭──── locals ────â•Ū                                                                │
│   1857 │   │   each CPU. If not a list with one element is returned.                           │ percpu = False │                                                                │
│   1858 │   │   """                                                                             ╰────────────────â•Ŋ                                                                │
│ ❱ 1859 │   │   ret = _psplatform.cpu_freq()                                                                                                                                      │
│   1860 │   │   if percpu:                                                                                                                                                        │
│   1861 │   │   │   return ret                                                                                                                                                    │
│   1862 │   │   else:                                                                                                                                                             │
│                                                                                                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/ml-data/lib/python3.9/site-packages/psutil/_psosx.py:180 in cpu_freq                                                                  │
│                                                                                                                                                                                  │
│   177 │   Also, the returned frequency never changes, see:                                                                                                                       │
│   178 │   https://arstechnica.com/civis/viewtopic.php?f=19&t=465002                                                                                                              │
│   179 │   """                                                                                                                                                                    │
│ ❱ 180 │   curr, min_, max_ = cext.cpu_freq()                                                                                                                                     │
│   181 │   return [_common.scpufreq(curr, min_, max_)]                                                                                                                            │
│   182                                                                                                                                                                            │
│   183                                                                                                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────â•Ŋ
FileNotFoundError: [Errno 2] No such file or directory (originated from sysctlbyname('hw.cpufrequency'))

System Info:

CPU:

âŊ sysctl -a | grep machdep.cpu
machdep.cpu.brand_string: Apple M1
machdep.cpu.core_count: 8
machdep.cpu.cores_per_package: 8
machdep.cpu.logical_per_package: 8
machdep.cpu.thread_count: 8

OS:

System Software Overview:

      System Version: macOS 12.0.1 (21A559)
      Kernel Version: Darwin 21.1.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: ----
      User Name: ----
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: ----
nschloe commented 3 years ago

Duplicate of #25.