diff --git a/doc/changes/dev/13593.other.rst b/doc/changes/dev/13593.other.rst new file mode 100644 index 00000000000..fe9694f2c92 --- /dev/null +++ b/doc/changes/dev/13593.other.rst @@ -0,0 +1 @@ +make :func:`mne.sys_info` work on Windows systems with Powershell version 7+, by `Marijn van Vliet`_ diff --git a/mne/utils/config.py b/mne/utils/config.py index 9d5cf9f3c40..4bc90072401 100644 --- a/mne/utils/config.py +++ b/mne/utils/config.py @@ -681,11 +681,9 @@ def _get_gpu_info(): def _get_total_memory(): """Return the total memory of the system in bytes.""" if platform.system() == "Windows": + ps = shutil.which("pwsh") or shutil.which("powershell") o = subprocess.check_output( - [ - "powershell.exe", - "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory", - ] + [ps, "-c", "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory"] ).decode() # Can get for example a "running scripts is disabled on this system" # error where "o" will be a long string rather than an int @@ -708,8 +706,9 @@ def _get_total_memory(): def _get_cpu_brand(): """Return the CPU brand string.""" if platform.system() == "Windows": + ps = shutil.which("pwsh") or shutil.which("powershell") o = subprocess.check_output( - ["powershell.exe", "(Get-CimInstance Win32_Processor).Name"] + [ps, "-c", "(Get-CimInstance Win32_Processor).Name"] ).decode() cpu_brand = o.strip().splitlines()[-1] elif platform.system() == "Linux":