Skip to content

Commit 3b4604a

Browse files
committed
Make mne.sys_info() work with powershell 7+
1 parent 01b5bd4 commit 3b4604a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

mne/utils/config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,9 @@ def _get_gpu_info():
681681
def _get_total_memory():
682682
"""Return the total memory of the system in bytes."""
683683
if platform.system() == "Windows":
684+
ps = shutil.which("pwsh") or shutil.which("powershell")
684685
o = subprocess.check_output(
685-
[
686-
"powershell.exe",
687-
"(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory",
688-
]
686+
[ps, "-c", "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory"]
689687
).decode()
690688
# Can get for example a "running scripts is disabled on this system"
691689
# error where "o" will be a long string rather than an int
@@ -708,8 +706,9 @@ def _get_total_memory():
708706
def _get_cpu_brand():
709707
"""Return the CPU brand string."""
710708
if platform.system() == "Windows":
709+
ps = shutil.which("pwsh") or shutil.which("powershell")
711710
o = subprocess.check_output(
712-
["powershell.exe", "(Get-CimInstance Win32_Processor).Name"]
711+
[ps, "-c", "(Get-CimInstance Win32_Processor).Name"]
713712
).decode()
714713
cpu_brand = o.strip().splitlines()[-1]
715714
elif platform.system() == "Linux":

0 commit comments

Comments
 (0)