Skip to content

BUG: Fix bug with sys_info on Windows #13310

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

Merged
merged 5 commits into from
Jul 10, 2025
Merged

BUG: Fix bug with sys_info on Windows #13310

merged 5 commits into from
Jul 10, 2025

Conversation

larsoner
Copy link
Member

@larsoner larsoner commented Jul 7, 2025

Fixed a little bug I hit on Windows where not having permissions to call a command-line function caused a ValueError

Closes #13154

@larsoner larsoner added this to the 1.10 milestone Jul 7, 2025
@larsoner
Copy link
Member Author

larsoner commented Jul 7, 2025

Tacked on a little fix for #13154 as well, ready for review/merge from my end!

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being on mne main, I can run mne sys_info just fine on a non-elevated powershell (i.e., I do not need this PR for it to work). Do I need to call something special to reproduce the error?

@larsoner
Copy link
Member Author

Not 100% sure what needs to be done but without this change this is what I see:

CPU                  Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 cores)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\larsoner\mne-python\1.9.0_0\Scripts\mne.exe\__main__.py", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\larsoner\python\mne-python\mne\commands\utils.py", line 109, in main
    cmd.run()
    ~~~~~~~^^
  File "C:\Users\larsoner\python\mne-python\mne\commands\mne_sys_info.py", line 58, in run
    mne.sys_info(
    ~~~~~~~~~~~~^
        show_paths=options.show_paths,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        check_version=options.check_version,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\larsoner\python\mne-python\mne\utils\config.py", line 781, in sys_info
    total_memory = _get_total_memory()
  File "C:\Users\larsoner\python\mne-python\mne\utils\config.py", line 690, in _get_total_memory
    total_memory = int(o)
ValueError: invalid literal for int() with base 10: ". : File C:\\Users\\larsoner\\Documents\\WindowsPowerShell\\profile.ps1 cannot be loaded because running scripts is \ndisabled on this system. For more information, see about_Execution_Policies at \n

@larsoner
Copy link
Member Author

These seem to have relevant info:

So on my machine I have:

PS> Get-ExecutionPolicy -List
        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

I can confirm that setting:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

allows things to work without this change, and

Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope LocalMachine

brings back the error above on main. So you can mess with these locally to try to replicate if you want. FWIW this is on Windows 10, if it matters.

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I have the ExecutionPolicy that allows things to work without this change. This is on Windows 11.

larsoner and others added 2 commits July 10, 2025 10:48
Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
@larsoner larsoner enabled auto-merge (squash) July 10, 2025 14:48
@larsoner larsoner merged commit 3612f7b into mne-tools:main Jul 10, 2025
32 checks passed
@larsoner larsoner deleted the mem branch July 10, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trouble with measurement dates when anonymizing or writing epochs data
2 participants