Skip to content
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

subprocess env is not set properly #6988

Closed
kingjr opened this issue Oct 28, 2019 · 5 comments · Fixed by #6991
Closed

subprocess env is not set properly #6988

kingjr opened this issue Oct 28, 2019 · 5 comments · Fixed by #6991

Comments

@kingjr
Copy link
Member

kingjr commented Oct 28, 2019

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)

@agramfort
Copy link
Member

agramfort commented Oct 28, 2019 via email

@kingjr
Copy link
Member Author

kingjr commented Oct 28, 2019

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

@agramfort
Copy link
Member

agramfort commented Oct 28, 2019 via email

@larsoner
Copy link
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).

@kingjr
Copy link
Member Author

kingjr commented Oct 28, 2019

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants