# Buggy code
def __init__(self, description, enabled=True, json=False):
    """
    Args:
        description (str):
            The name of the progress bar, shown on left side of output.
        enabled (bool):
            If False, usage is a no-op.
        json (bool):
            If true, outputs json progress to stdout rather than a progress bar.
            Currently, the json format assumes this is only used for "fetch", which
            maintains backward compatibility with conda 4.3 and earlier behavior.
    """
    self.description = description
    self.enabled = enabled
    self.json = json

    if json:
        pass
    elif enabled:
        bar_format = "{desc}{bar} | {percentage:3.0f}% "
        self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def __init__(self, description, enabled=True, json=False):
    """
    Args:
        description (str):
            The name of the progress bar, shown on left side of output.
        enabled (bool):
            If False, usage is a no-op.
        json (bool):
            If true, outputs json progress to stdout rather than a progress bar.
            Currently, the json format assumes this is only used for "fetch", which
            maintains backward compatibility with conda 4.3 and earlier behavior.
    """
    self.description = description
    self.enabled = enabled
    self.json = json

    if json:
        pass
    elif enabled:
        bar_format = "{desc}{bar} | {percentage:3.0f}% "
        try:
            self.pbar = tqdm(
                desc=description, bar_format=bar_format, ascii=True, total=1
            )
        except EnvironmentError as e:
            if e.errno in (EPIPE, ESHUTDOWN):
                self.enabled = False
            else:
                raise