# Buggy code
def __init__(
    self,
    iterable=None,
    desc=None,
    total=None,
    leave=True,
    file=None,
    ncols=None,
    mininterval=0.1,
    maxinterval=10.0,
    miniters=None,
    ascii=None,
    disable=False,
    unit="it",
    unit_scale=False,
    dynamic_ncols=False,
    smoothing=0.3,
    bar_format=None,
    initial=0,
    position=None,
    postfix=None,
    unit_divisor=1000,
    gui=False,
    **kwargs,
):
    """
    Parameters
    ----------
    iterable  : iterable, optional
        Iterable to decorate with a progressbar.
        Leave blank to manually manage the updates.
    desc  : str, optional
        Prefix for the progressbar.
    total  : int, optional
        The number of expected iterations. If unspecified,
        len(iterable) is used if possible. As a last resort, only basic
        progress statistics are displayed (no ETA, no progressbar).
        If `gui` is True and this parameter needs subsequent updating,
        specify an initial arbitrary large positive integer,
        e.g. int(9e9).
    leave  : bool, optional
        If [default: True], keeps all traces of the progressbar
        upon termination of iteration.
    file  : `io.TextIOWrapper` or `io.StringIO`, optional
        Specifies where to output the progress messages
        (default: sys.stderr). Uses `file.write(str)` and `file.flush()`
        methods.
    ncols  : int, optional
        The width of the entire output message. If specified,
        dynamically resizes the progressbar to stay within this bound.
        If unspecified, attempts to use environment width. The
        fallback is a meter width of 10 and no limit for the counter and
        statistics. If 0, will not print any meter (only stats).
    mininterval  : float, optional
        Minimum progress display update interval, in seconds [default: 0.1].
    maxinterval  : float, optional
        Maximum progress display update interval, in seconds [default: 10].
        Automatically adjusts `miniters` to correspond to `mininterval`
        after long display update lag. Only works if `dynamic_miniters`
        or monitor thread is enabled.
    miniters  : int, optional
        Minimum progress display update interval, in iterations.
        If 0 and `dynamic_miniters`, will automatically adjust to equal
        `mininterval` (more CPU efficient, good for tight loops).
        If > 0, will skip display of specified number of iterations.
        Tweak this and `mininterval` to get very efficient loops.
        If your progress is erratic with both fast and slow iterations
        (network, skipping items, etc) you should set miniters=1.
    ascii  : bool, optional
        If unspecified or False, use unicode (smooth blocks) to fill
        the meter. The fallback is to use ASCII characters `1-9 #`.
    disable  : bool, optional
        Whether to disable the entire progressbar wrapper
        [default: False]. If set to None, disable on non-TTY.
    unit  : str, optional
        String that will be used to define the unit of each iteration
        [default: it].
    unit_scale  : bool or int or float, optional
        If 1 or True, the number of iterations will be reduced/scaled
        automatically and a metric prefix following the
        International System of Units standard will be added
        (kilo, mega, etc.) [default: False]. If any other non-zero
        number, will scale `total` and `n`.
    dynamic_ncols  : bool, optional
        If set, constantly alters `ncols` to the environment (allowing
        for window resizes) [default: False].
    smoothing  : float, optional
        Exponential moving average smoothing factor for speed estimates
        (ignored in GUI mode). Ranges from 0 (average speed) to 1
        (current/instantaneous speed) [default: 0.3].
    bar_format  : str, optional
        Specify a custom bar string formatting. May impact performance.
        [default: '{l_bar}{bar}{r_bar}'], where
        l_bar='{desc}: {percentage:3.0f}%|' and
        r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
          '{rate_fmt}{postfix}]'
        Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
          percentage, rate, rate_fmt, rate_noinv, rate_noinv_fmt,
          rate_inv, rate_inv_fmt, elapsed, remaining, desc, postfix.
        Note that a trailing ": " is automatically removed after {desc}
        if the latter is empty.
    initial  : int, optional
        The initial counter value. Useful when restarting a progress
        bar [default: 0].
    position  : int, optional
        Specify the line offset to print this bar (starting from 0)
        Automatic if unspecified.
        Useful to manage multiple bars at once (eg, from threads).
    postfix  : dict or *, optional
        Specify additional stats to display at the end of the bar.
        Calls `set_postfix(**postfix)` if possible (dict).
    unit_divisor  : float, optional
        [default: 1000], ignored unless `unit_scale` is True.
    gui  : bool, optional
        WARNING: internal parameter - do not use.
        Use tqdm_gui(...) instead. If set, will attempt to use
        matplotlib animations for a graphical output [default: False].
    Returns
    -------
    out  : decorated iterator.
    """

    if file is None:
        file = sys.stderr

    if disable is None and hasattr(file, "isatty") and not file.isatty():
        disable = True

    if disable:
        self.iterable = iterable
        self.disable = disable
        self.pos = self._get_free_pos(self)
        self._instances.remove(self)
        self.n = initial
        return

    if kwargs:
        self.disable = True
        self.pos = self._get_free_pos(self)
        self._instances.remove(self)
        raise (
            TqdmDeprecationWarning(
                """\
`nested` is deprecated and automated. Use position instead for manual control.
""",
                fp_write=getattr(file, "write", sys.stderr.write),
            )
            if "nested" in kwargs
            else TqdmKeyError("Unknown argument(s): " + str(kwargs))
        )

    # Preprocess the arguments
    if total is None and iterable is not None:
        try:
            total = len(iterable)
        except (TypeError, AttributeError):
            total = None

    if (
        (ncols is None) and (file in (sys.stderr, sys.stdout))
    ) or dynamic_ncols:  # pragma: no cover
        if dynamic_ncols:
            dynamic_ncols = _environ_cols_wrapper()
            if dynamic_ncols:
                ncols = dynamic_ncols(file)
            # elif ncols is not None:
            #     ncols = 79
        else:
            _dynamic_ncols = _environ_cols_wrapper()
            if _dynamic_ncols:
                ncols = _dynamic_ncols(file)
            # else:
            #     ncols = 79

    if miniters is None:
        miniters = 0
        dynamic_miniters = True
    else:
        dynamic_miniters = False

    if mininterval is None:
        mininterval = 0

    if maxinterval is None:
        maxinterval = 0

    if ascii is None:
        ascii = not _supports_unicode(file)

    if bar_format and not ascii:
        # Convert bar format into unicode since terminal uses unicode
        bar_format = _unicode(bar_format)

    if smoothing is None:
        smoothing = 0

    # Store the arguments
    self.iterable = iterable
    self.desc = desc or ""
    self.total = total
    self.leave = leave
    self.fp = file
    self.ncols = ncols
    self.mininterval = mininterval
    self.maxinterval = maxinterval
    self.miniters = miniters
    self.dynamic_miniters = dynamic_miniters
    self.ascii = ascii
    self.disable = disable
    self.unit = unit
    self.unit_scale = unit_scale
    self.unit_divisor = unit_divisor
    self.gui = gui
    self.dynamic_ncols = dynamic_ncols
    self.smoothing = smoothing
    self.avg_time = None
    self._time = time
    self.bar_format = bar_format
    self.postfix = None
    if postfix:
        try:
            self.set_postfix(refresh=False, **postfix)
        except TypeError:
            self.postfix = postfix

    # Init the iterations counters
    self.last_print_n = initial
    self.n = initial

    # if nested, at initial sp() call we replace '\r' by '\n' to
    # not overwrite the outer progress bar
    if position is None:
        self.pos = self._get_free_pos(self)
    else:  # mark fixed positions as negative
        self.pos = -position

    if not gui:
        # Initialize the screen printer
        self.sp = self.status_printer(self.fp)
        with self._lock:
            if self.pos:
                self.moveto(abs(self.pos))
            self.sp(self.__repr__(elapsed=0))
            if self.pos:
                self.moveto(-abs(self.pos))

    # Init the time counter
    self.last_print_t = self._time()
    # NB: Avoid race conditions by setting start_t at the very end of init
    self.start_t = self.last_print_t


# Traceback (RuntimeError)
[s1758208@login04(eddie) ~]$ conda create -n test
[s1758208@login04(eddie) ~]$ conda activate test
(test) [s1758208@login04(eddie) ~]$ conda install python
Solving environment: done

## Package Plan ##

environment location: /exports/csce/eddie/ph/groups/rbm_ml/michael/myconda/envs/test

added / updated specs:
- python


The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
python-3.6.4               |       hc3d631a_3        29.1 MB
libstdcxx-ng-7.2.0         |       hdf63c60_3         2.5 MB
certifi-2018.1.18          |           py36_0         144 KB
zlib-1.2.11                |       ha838bed_2         101 KB
sqlite-3.22.0              |       h1bed415_0         1.5 MB
wheel-0.30.0               |   py36hfd4bba0_1          67 KB
openssl-1.0.2n             |       hb7f436b_0         3.4 MB
libffi-3.2.1               |       hd88cf55_4          43 KB
libgcc-ng-7.2.0            |       hdf63c60_3         6.1 MB
ncurses-6.0                |       h9df7e31_2         920 KB
tk-8.6.7                   |       hc745277_3         3.2 MB
setuptools-38.5.1          |           py36_0         525 KB
pip-9.0.1                  |           py36_5         2.2 MB
libedit-3.1                |       heed3624_0         171 KB
ca-certificates-2017.08.26 |       h1d4fec5_0         263 KB
------------------------------------------------------------
Total:        50.2 MB

The following NEW packages will be INSTALLED:

ca-certificates: 2017.08.26-h1d4fec5_0
certifi:         2018.1.18-py36_0
libedit:         3.1-heed3624_0
libffi:          3.2.1-hd88cf55_4
libgcc-ng:       7.2.0-hdf63c60_3
libstdcxx-ng:    7.2.0-hdf63c60_3
ncurses:         6.0-h9df7e31_2
openssl:         1.0.2n-hb7f436b_0
pip:             9.0.1-py36_5
python:          3.6.4-hc3d631a_3
readline:        7.0-ha6073c6_4
setuptools:      38.5.1-py36_0
sqlite:          3.22.0-h1bed415_0
tk:              8.6.7-hc745277_3
wheel:           0.30.0-py36hfd4bba0_1
xz:              5.2.3-h55aa19d_2
zlib:            1.2.11-ha838bed_2

Proceed ([y]/n)? y


Downloading and Extracting Packages
python 3.6.4: ########################################################## | 100%
libstdcxx-ng 7.2.0: #################################################### | 100%
certifi 2018.1.18: ##################################################### | 100%

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/exceptions.py", line 789, in __call__
return func(*args, **kwargs)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/s1758208/miniconda3/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/s1758208/miniconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 584, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 599, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/common/io.py", line 390, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 388, in __new__
cls.monitor = TMonitor(cls, cls.monitor_interval)
File "/home/s1758208/miniconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 83, in __init__
self.start()
File "/home/s1758208/miniconda3/lib/python3.6/threading.py", line 846, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

# Fixed code
def __init__(
    self,
    iterable=None,
    desc=None,
    total=None,
    leave=True,
    file=None,
    ncols=None,
    mininterval=0.1,
    maxinterval=10.0,
    miniters=None,
    ascii=None,
    disable=False,
    unit="it",
    unit_scale=False,
    dynamic_ncols=False,
    smoothing=0.3,
    bar_format=None,
    initial=0,
    position=None,
    postfix=None,
    unit_divisor=1000,
    gui=False,
    **kwargs,
):
    """
    Parameters
    ----------
    iterable  : iterable, optional
        Iterable to decorate with a progressbar.
        Leave blank to manually manage the updates.
    desc  : str, optional
        Prefix for the progressbar.
    total  : int, optional
        The number of expected iterations. If unspecified,
        len(iterable) is used if possible. As a last resort, only basic
        progress statistics are displayed (no ETA, no progressbar).
        If `gui` is True and this parameter needs subsequent updating,
        specify an initial arbitrary large positive integer,
        e.g. int(9e9).
    leave  : bool, optional
        If [default: True], keeps all traces of the progressbar
        upon termination of iteration.
    file  : `io.TextIOWrapper` or `io.StringIO`, optional
        Specifies where to output the progress messages
        (default: sys.stderr). Uses `file.write(str)` and `file.flush()`
        methods.
    ncols  : int, optional
        The width of the entire output message. If specified,
        dynamically resizes the progressbar to stay within this bound.
        If unspecified, attempts to use environment width. The
        fallback is a meter width of 10 and no limit for the counter and
        statistics. If 0, will not print any meter (only stats).
    mininterval  : float, optional
        Minimum progress display update interval, in seconds [default: 0.1].
    maxinterval  : float, optional
        Maximum progress display update interval, in seconds [default: 10].
        Automatically adjusts `miniters` to correspond to `mininterval`
        after long display update lag. Only works if `dynamic_miniters`
        or monitor thread is enabled.
    miniters  : int, optional
        Minimum progress display update interval, in iterations.
        If 0 and `dynamic_miniters`, will automatically adjust to equal
        `mininterval` (more CPU efficient, good for tight loops).
        If > 0, will skip display of specified number of iterations.
        Tweak this and `mininterval` to get very efficient loops.
        If your progress is erratic with both fast and slow iterations
        (network, skipping items, etc) you should set miniters=1.
    ascii  : bool, optional
        If unspecified or False, use unicode (smooth blocks) to fill
        the meter. The fallback is to use ASCII characters `1-9 #`.
    disable  : bool, optional
        Whether to disable the entire progressbar wrapper
        [default: False]. If set to None, disable on non-TTY.
    unit  : str, optional
        String that will be used to define the unit of each iteration
        [default: it].
    unit_scale  : bool, optional
        If set, the number of iterations will be reduced/scaled
        automatically and a metric prefix following the
        International System of Units standard will be added
        (kilo, mega, etc.) [default: False].
    dynamic_ncols  : bool, optional
        If set, constantly alters `ncols` to the environment (allowing
        for window resizes) [default: False].
    smoothing  : float, optional
        Exponential moving average smoothing factor for speed estimates
        (ignored in GUI mode). Ranges from 0 (average speed) to 1
        (current/instantaneous speed) [default: 0.3].
    bar_format  : str, optional
        Specify a custom bar string formatting. May impact performance.
        If unspecified, will use '{l_bar}{bar}{r_bar}', where l_bar is
        '{desc}{percentage:3.0f}%|' and r_bar is
        '| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]'
        Possible vars: bar, n, n_fmt, total, total_fmt, percentage,
        rate, rate_fmt, elapsed, remaining, l_bar, r_bar, desc.
    initial  : int, optional
        The initial counter value. Useful when restarting a progress
        bar [default: 0].
    position  : int, optional
        Specify the line offset to print this bar (starting from 0)
        Automatic if unspecified.
        Useful to manage multiple bars at once (eg, from threads).
    postfix  : dict, optional
        Specify additional stats to display at the end of the bar.
    unit_divisor  : float, optional
        [default: 1000], ignored unless `unit_scale` is True.
    gui  : bool, optional
        WARNING: internal parameter - do not use.
        Use tqdm_gui(...) instead. If set, will attempt to use
        matplotlib animations for a graphical output [default: False].

    Returns
    -------
    out  : decorated iterator.
    """

    if disable is None and hasattr(file, "isatty") and not file.isatty():
        disable = True

    if disable:
        self.iterable = iterable
        self.disable = disable
        self.pos = self._get_free_pos(self)
        self._instances.remove(self)
        return

    if file is None:
        file = sys.stderr

    if kwargs:
        self.disable = True
        self.pos = self._get_free_pos(self)
        self._instances.remove(self)
        raise (
            TqdmDeprecationWarning(
                """\
`nested` is deprecated and automated. Use position instead for manual control.
""",
                fp_write=getattr(file, "write", sys.stderr.write),
            )
            if "nested" in kwargs
            else TqdmKeyError("Unknown argument(s): " + str(kwargs))
        )

    # Preprocess the arguments
    if total is None and iterable is not None:
        try:
            total = len(iterable)
        except (TypeError, AttributeError):
            total = None

    if (
        (ncols is None) and (file in (sys.stderr, sys.stdout))
    ) or dynamic_ncols:  # pragma: no cover
        if dynamic_ncols:
            dynamic_ncols = _environ_cols_wrapper()
            if dynamic_ncols:
                ncols = dynamic_ncols(file)
            # elif ncols is not None:
            #     ncols = 79
        else:
            _dynamic_ncols = _environ_cols_wrapper()
            if _dynamic_ncols:
                ncols = _dynamic_ncols(file)
            # else:
            #     ncols = 79

    if miniters is None:
        miniters = 0
        dynamic_miniters = True
    else:
        dynamic_miniters = False

    if mininterval is None:
        mininterval = 0

    if maxinterval is None:
        maxinterval = 0

    if ascii is None:
        ascii = not _supports_unicode(file)

    if bar_format and not ascii:
        # Convert bar format into unicode since terminal uses unicode
        bar_format = _unicode(bar_format)

    if smoothing is None:
        smoothing = 0

    # Store the arguments
    self.iterable = iterable
    self.desc = desc + ": " if desc else ""
    self.total = total
    self.leave = leave
    self.fp = file
    self.ncols = ncols
    self.mininterval = mininterval
    self.maxinterval = maxinterval
    self.miniters = miniters
    self.dynamic_miniters = dynamic_miniters
    self.ascii = ascii
    self.disable = disable
    self.unit = unit
    self.unit_scale = unit_scale
    self.unit_divisor = unit_divisor
    self.gui = gui
    self.dynamic_ncols = dynamic_ncols
    self.smoothing = smoothing
    self.avg_time = None
    self._time = time
    self.bar_format = bar_format
    self.postfix = None
    if postfix:
        self.set_postfix(**postfix)

    # Init the iterations counters
    self.last_print_n = initial
    self.n = initial

    # if nested, at initial sp() call we replace '\r' by '\n' to
    # not overwrite the outer progress bar
    if position is None:
        self.pos = self._get_free_pos(self)
    else:
        self.pos = position
        self._instances.remove(self)

    if not gui:
        # Initialize the screen printer
        self.sp = self.status_printer(self.fp)
        if self.pos:
            self.moveto(self.pos)
        self.sp(
            self.format_meter(
                self.n,
                total,
                0,
                (dynamic_ncols(file) if dynamic_ncols else ncols),
                self.desc,
                ascii,
                unit,
                unit_scale,
                None,
                bar_format,
                self.postfix,
                unit_divisor,
            )
        )
        if self.pos:
            self.moveto(-self.pos)

    # Init the time counter
    self.last_print_t = self._time()
    # NB: Avoid race conditions by setting start_t at the very end of init
    self.start_t = self.last_print_t