Skip to content

TypeError: environment can only contain strings #2509

Closed
@ggsf13

Description

@ggsf13

Summary

I'm working on an image processing task with nipype, and I got the following problem

Actual behavior

Expected behavior

How to replicate the behavior

Script/Workflow details

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\study\project\3D cnn\3DUnetCNN-master\brats\preprocess.py", line 155, in convert_brats_data
    no_bias_correction_modalities=no_bias_correction_modalities)
  File "D:\study\project\3D cnn\3DUnetCNN-master\brats\preprocess.py", line 124, in convert_brats_folder
    normalize_image(image_file, out_file, bias_correction=perform_bias_correction)
  File "D:\study\project\3D cnn\3DUnetCNN-master\brats\preprocess.py", line 112, in normalize_image
    correct_bias(in_file, out_file)
  File "D:\study\project\3D cnn\3DUnetCNN-master\brats\preprocess.py", line 70, in correct_bias
    done = correct.run()
  File "D:\softwares\Annoconda3\lib\site-packages\nipype\interfaces\base\core.py", line 498, in run
    version=self.version)
  File "D:\softwares\Annoconda3\lib\site-packages\nipype\interfaces\ants\base.py", line 125, in version
    return Info.version()
  File "D:\softwares\Annoconda3\lib\site-packages\nipype\interfaces\base\core.py", line 1283, in version
    terminal_output='allatonce').run()
  File "D:\softwares\Annoconda3\lib\site-packages\nipype\interfaces\base\core.py", line 516, in run
    runtime = self._run_interface(runtime)
  File "D:\softwares\Annoconda3\lib\site-packages\nipype\interfaces\base\core.py", line 1020, in _run_interface
    runtime = run_command(runtime, output=self.terminal_output)
  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

here are the codes that produced the error:

        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)

Platform details:

{'pkg_path': 'D:\\softwares\\Annoconda3\\lib\\site-packages\\nipype',
 'commit_source': 'installation',
 'commit_hash': 'bded0d02',
 'nipype_version': '1.0.1',
 'sys_version': '3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]',
 'sys_executable': 'D:\\softwares\\Annoconda3\\python.exe',
 'sys_platform': 'win32',
 'numpy_version': '1.13.3',
 'scipy_version': '0.19.1',
 'networkx_version': '2.0',
 'nibabel_version': '2.2.1',
 'traits_version': '4.6.0'}
1.0.1

Execution environment

can anyone help me with this? any suggestion is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions