# Buggy code
def print_packages(
    prefix,
    regex=None,
    format="human",
    piplist=False,
    json=False,
    show_channel_urls=context.show_channel_urls,
):
    if not isdir(prefix):
        raise CondaEnvironmentNotFoundError(prefix)

    if not json:
        if format == "human":
            print("# packages in environment at %s:" % prefix)
            print("#")
        if format == "export":
            print_export_header()

    installed = linked(prefix)
    log.debug("installed conda packages:\n%s", installed)
    if piplist and context.use_pip and format == "human":
        other_python = get_egg_info(prefix)
        log.debug("other installed python packages:\n%s", other_python)
        installed.update(other_python)

    exitcode, output = list_packages(
        prefix, installed, regex, format=format, show_channel_urls=show_channel_urls
    )
    if not json:
        print("\n".join(map(text_type, output)))
    else:
        stdout_json(output)
    return exitcode


# Traceback (ImportError)
Traceback (most recent call last):
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 573, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 98, in _main
imported = importlib.import_module(module)
File "/Users/tasalta/anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/cli/main_list.py", line 20, in <module>
from ..egg_info import get_egg_info
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/egg_info.py", line 15, in <module>
from .misc import rel_path
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/misc.py", line 19, in <module>
from .core.index import get_index, _supplement_index_with_cache
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .repodata import collect_all_repodata
File "/Users/tasalta/anaconda/lib/python2.7/site-packages/conda/core/repodata.py", line 21, in <module>
from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: cannot import name InsecureRequestWarning


at throwCondaError (/Applications/GraphLab Create Launcher.app/Contents/Resources/app.asar/utils/conda.js:117:9)
at runConda (/Applications/GraphLab Create Launcher.app/Contents/Resources/app.asar/utils/conda.js:146:5)
at Object.info (/Applications/GraphLab Create Launcher.app/Contents/Resources/app.asar/utils/conda.js:395:10)
at Object.isGLCLauncherReady (/Applications/GraphLab Create Launcher.app/Contents/Resources/app.asar/utils/systemState.js:207:27)
at [object Object].onWindowOpen [as _onTimeout] (/Applications/GraphLab Create Launcher.app/Contents/Resources/app.asar/main.js:144:57)
at Timer.listOnTimeout (timers.js:89:15)

# Fixed code
def print_packages(
    prefix,
    regex=None,
    format="human",
    piplist=False,
    json=False,
    show_channel_urls=None,
):
    from .common import stdout_json
    from ..base.context import context
    from ..common.compat import text_type
    from ..core.linked_data import linked
    from ..egg_info import get_egg_info

    if not isdir(prefix):
        from ..exceptions import CondaEnvironmentNotFoundError

        raise CondaEnvironmentNotFoundError(prefix)

    if not json:
        if format == "human":
            print("# packages in environment at %s:" % prefix)
            print("#")
        if format == "export":
            print_export_header(context.subdir)

    installed = linked(prefix)
    log.debug("installed conda packages:\n%s", installed)
    if piplist and context.use_pip and format == "human":
        other_python = get_egg_info(prefix)
        log.debug("other installed python packages:\n%s", other_python)
        installed.update(other_python)

    exitcode, output = list_packages(
        prefix, installed, regex, format=format, show_channel_urls=show_channel_urls
    )
    if not json:
        print("\n".join(map(text_type, output)))
    else:
        stdout_json(output)
    return exitcode