TypeError:环境只能包含字符串

时间:2018-03-24 13:48:33

标签: python

我现在正在使用nipype进行图像处理项目,我的python版本是3.6,我收到了这个错误

File "D:\softwares\Annoconda3\lib\site- 
packages\nipype\interfaces\base\core.py", line 750, in run_command
close_fds=False,
File "D:\softwares\Annoconda3\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "D:\softwares\Annoconda3\lib\subprocess.py", line 997, in 
_execute_child
startupinfo)
TypeError: environment can only contain strings}

以下是导致错误的代码

        def _execute_child(self, args, executable, preexec_fn, close_fds,
                       pass_fds, cwd, env,
                       startupinfo, creationflags, shell,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite,
                       unused_restore_signals, unused_start_new_session):
        """Execute program (MS Windows version)"""

        assert not pass_fds, "pass_fds not supported on Windows."

        if not isinstance(args, str):
            args = list2cmdline(args)

        # Process startup details
        if startupinfo is None:
            startupinfo = STARTUPINFO()
        if -1 not in (p2cread, c2pwrite, errwrite):
            startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES
            startupinfo.hStdInput = p2cread
            startupinfo.hStdOutput = c2pwrite
            startupinfo.hStdError = errwrite

        if shell:
            startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW
            startupinfo.wShowWindow = _winapi.SW_HIDE
            comspec = os.environ.get("COMSPEC", "cmd.exe")
            args = '{} /c "{}"'.format (comspec, args)

        # Start the process
        try:
            hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                                     # no special security
                                     None, None,
                                     int(not close_fds),
                                     creationflags,
                                     env,
                                     os.fspath(cwd) if cwd is not None else None,
                                     startupinfo)

任何人都可以帮我解决这个问题吗?任何帮助将不胜感激

0 个答案:

没有答案