Skip to content

subprocess env is not set properly #6988

Closed

Description

@kingjr

While running mne.bem.mne_make_watershed_bem I ran into a unspecific error:
Error: io.UnsupportedOperation: fileno

which is due to a subprocess error triggered earlier ('mri_watershed not found').

I tried changing FREESURFER_HOME via mne.set_config without luck.

I manually changed run_subprocess, as follow, which fixed the issue.

def run_subprocess(command, return_code=False, verbose=None, *args, **kwargs):    
    import subprocess, os
    my_env = os.environ.copy()
    my_env["PATH"] = "/usr/sbin:/sbin:" + my_env["PATH"]

    cp = subprocess.run(command, 
                        env=my_env,
                        universal_newlines=True, 
                        stdout=subprocess.PIPE, 
                        stderr=subprocess.PIPE)
    return cp.stdout, cp.stderr

(And if someone opens a PR, you can pass the missing overwrite param here https://github.com/mne-tools/mne-python/blob/master/mne/bem.py#L1156)

Activity

  1. agramfort commented on Oct 28, 2019

    @agramfort
    SponsorMember
  2. kingjr commented on Oct 28, 2019

    @kingjr
    MemberAuthor

    you hacked the path?

    In the fix yes, else no.

    this function looks very different from

    Yes, I went for the simplest possible fix ;)

    This solved the issue for me, but I don't want to open a PR, because it's not a pure-python, platform-independent, easy-to-debug issue.

    are you using latest release/master?

    yes

  3. agramfort commented on Oct 28, 2019

    @agramfort
    SponsorMember
  4. larsoner commented on Oct 28, 2019

    @larsoner
    Member

    #6991 should fix it. Either use that branch, or export FREESURFER_HOME=... in your terminal before starting the Python interpreter (which is probably what most folks do, which is why nobody hit/reported this yet).

  5. kingjr commented on Oct 28, 2019

    @kingjr
    MemberAuthor

    FWIW, I did export FREESURFER_HOME prior to python interpreter.

    #6991 seems to works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions