pytest-monitor
pytest-monitor copied to clipboard
Running pytest after install pytest-monitor results in `FileNotFoundError: [Errno 2] No such file or directory (originated from sysctl(HW_CPU_FREQ))`
After installing pytest-monitor, and running pytest, I get an error:
pip install pytest-monitor pytest
Stack trace:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/_pytest/main.py", line 266, in wrap_session
INTERNALERROR> config.hook.pytest_sessionstart(session=session)
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pluggy/_callers.py", line 34, in _multicall
INTERNALERROR> next(gen) # first yield
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pytest_monitor/pytest_monitor.py", line 194, in pytest_sessionstart
INTERNALERROR> session.pytest_monitor.compute_info(session.config.option.mtr_description,
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pytest_monitor/session.py", line 85, in compute_info
INTERNALERROR> self.set_environment_info(ExecutionContext())
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/pytest_monitor/sys_utils.py", line 72, in __init__
INTERNALERROR> self.__cpu_freq_base = psutil.cpu_freq().current
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/psutil/__init__.py", line 1864, in cpu_freq
INTERNALERROR> ret = _psplatform.cpu_freq()
INTERNALERROR> File "/Users/justinzhao/mambaforge/envs/base38/lib/python3.8/site-packages/psutil/_psosx.py", line 179, in cpu_freq
INTERNALERROR> curr, min_, max_ = cext.cpu_freq()
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory (originated from sysctl(HW_CPU_FREQ))
Desktop:
- OS: macOS 12.5 monterey, M1 pro
- Python version: 3.8
- Pytest version: 7.1.2
- pytest-monitor version: 1.6.4
Hello
Thanks for submitting! I think psutil is not able to handle CPU frequency on Apple M1. As I just get a brand new laptop, I'll check this intuition and strive to provide a fix quickly. :)
Thanks @js-dieu! Congrats on your new laptop. Hopefully it's not a complicated fix.
@justinxzhao
Seems not complex. However, psutil has released a version with support for M1 chipset. Can you please give me the output of the following (to be run in your environment):
import memory_profiler as mp
import psutil as ps
print(ps.__version__)
print(mp.__version__)
It's strange that pip does not manage to give you the latest version of psutil .
@js-dieu
Here's my output:
>>> import memory_profiler as mp
import psutil as ps
print(ps.__version__)
print(mp.__version__)
>>> import psutil as ps
>>>
>>> print(ps.__version__)
5.9.1
>>> print(mp.__version__)
0.60.0
@justinxzhao
Ok, that means that psutil support of M1 is still partial. I am afraid we have to wait for them to fix this issue.
Hello @justinxzhao
I think that the latest release (1.6.5) should fix your issue. It is a fallback though, thus imperfect, but enough for you to run with pytest-monitor
. Waiting for psutil
to fix it completely though.
Do not hesitate to reopen if encounter another psutil related issue with pytest-monitor-1.6.5