# Buggy code
def can_handle(self):
    """
    Validates loader can process environment definition.
    :return: True or False
    """
    # TODO: log information about trying to find the package in binstar.org
    if self.valid_name():
        if self.binstar is None:
            self.msg = "Please install binstar"
            return False
        return self.package is not None and self.valid_package()
    return False


# Traceback (conda_env.exceptions.SpecNotFound)
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\tsnyder> which conda
C:\Users\tsnyder\Miniconda3\Scripts\conda.EXE
PS C:\Users\tsnyder> conda list
# packages in environment at C:\Users\tsnyder\Miniconda3:
#
conda                     4.1.11                   py35_0
conda-env                 2.5.2                    py35_0
console_shortcut          0.1.1                    py35_1
menuinst                  1.4.1                    py35_0
pip                       8.1.2                    py35_0
pycosat                   0.6.1                    py35_1
pycrypto                  2.6.1                    py35_4
python                    3.5.2                         0
pyyaml                    3.11                     py35_4
requests                  2.10.0                   py35_0
ruamel_yaml               0.11.14                  py35_0
setuptools                23.0.0                   py35_0
vs2015_runtime            14.0.25123                    0
wheel                     0.29.0                   py35_0
PS C:\Users\tsnyder> conda update --all
Fetching package metadata .........
Solving package specifications: ..........

Package plan for installation in environment C:\Users\tsnyder\Miniconda3:

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
conda-env-2.6.0            |                0          498 B
menuinst-1.4.2             |           py35_0         107 KB
pyyaml-3.12                |           py35_0         118 KB
requests-2.11.1            |           py35_0         665 KB
setuptools-27.2.0          |           py35_1         761 KB
conda-4.2.9                |           py35_0         428 KB
------------------------------------------------------------
Total:         2.0 MB

The following packages will be UPDATED:

conda:      4.1.11-py35_0 --> 4.2.9-py35_0
conda-env:  2.5.2-py35_0  --> 2.6.0-0
menuinst:   1.4.1-py35_0  --> 1.4.2-py35_0
pyyaml:     3.11-py35_4   --> 3.12-py35_0
requests:   2.10.0-py35_0 --> 2.11.1-py35_0
setuptools: 23.0.0-py35_0 --> 27.2.0-py35_1

Proceed ([y]/n)?

menuinst-1.4.2 100% |###############################| Time: 0:00:00 456.48 kB/s
Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00  71.13 kB/s
pyyaml-3.12-py 100% |###############################| Time: 0:00:00 541.10 kB/s
requests-2.11. 100% |###############################| Time: 0:00:00 885.09 kB/s
setuptools-27. 100% |###############################| Time: 0:00:00 976.23 kB/s
conda-4.2.9-py 100% |###############################| Time: 0:00:00 875.95 kB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
PS C:\Users\tsnyder> conda env create -h
usage: conda-env-script.py create [-h] [-f FILE] [-n ENVIRONMENT | -p PATH]
[-q] [--force] [--json] [--debug]
[--verbose]
[remote_definition]

Create an environment based on an environment file

Options:

positional arguments:
remote_definition     remote environment definition / IPython notebook

optional arguments:
-h, --help            Show this help message and exit.
-f FILE, --file FILE  environment definition file (default: environment.yml)
-n ENVIRONMENT, --name ENVIRONMENT
Name of environment (in
C:\Users\tsnyder\Miniconda3\envs).
-p PATH, --prefix PATH
Full path to environment prefix (default:
C:\Users\tsnyder\Miniconda3).
-q, --quiet
--force               force creation of environment (removing a previously
existing environment of the same name).
--json                Report all output as json. Suitable for using conda
programmatically.
--debug               Show debug output.
--verbose, -v         Use once for info, twice for debug.

examples:
conda env create
conda env create -n name
conda env create vader/deathstar
conda env create -f=/path/to/environment.yml
conda env create -f=/path/to/requirements.txt -n deathstar
conda env create -f=/path/to/requirements.txt -p /home/user/software/deathstar
PS C:\Users\tsnyder> conda env create tsnyder/python_training_2016_10
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Current conda install:

platform : win-64
conda version : 4.2.9
conda is private : False
conda-env version : 4.2.9
conda-build version : not installed
python version : 3.5.2.final.0
requests version : 2.11.1
root environment : C:\Users\tsnyder\Miniconda3  (writable)
default environment : C:\Users\tsnyder\Miniconda3
envs directories : C:\Users\tsnyder\Miniconda3\envs
package cache : C:\Users\tsnyder\Miniconda3\pkgs
channel URLs : https://repo.continuum.io/pkgs/free/win-64/
https://repo.continuum.io/pkgs/free/noarch/
https://repo.continuum.io/pkgs/pro/win-64/
https://repo.continuum.io/pkgs/pro/noarch/
https://repo.continuum.io/pkgs/msys2/win-64/
https://repo.continuum.io/pkgs/msys2/noarch/
config file : None
offline mode : False



`$ C:\Users\tsnyder\Miniconda3\Scripts\conda-env-script.py create tsnyder/python_training_2016_10`




Traceback (most recent call last):
File "C:\Users\tsnyder\Miniconda3\lib\site-packages\conda\exceptions.py", line 473, in conda_exception_handler
return_value = func(*args, **kwargs)
File "C:\Users\tsnyder\Miniconda3\lib\site-packages\conda_env\cli\main_create.py", line 81, in execute
directory=os.getcwd())
File "C:\Users\tsnyder\Miniconda3\lib\site-packages\conda_env\specs\__init__.py", line 23, in detect
raise SpecNotFound(build_message(specs))
conda_env.exceptions.SpecNotFound: Runtime error: Please install binstar
Please install nbformat:
conda install nbformat
Conda Env Exception: environment.yml file not found
There is no requirements.txt

# Fixed code
def can_handle(self):
    """
    Validates loader can process environment definition.
    :return: True or False
    """
    # TODO: log information about trying to find the package in binstar.org
    if self.valid_name():
        if self.binstar is None:
            self.msg = (
                "Anaconda Client is required to interact with anaconda.org or an "
                "Anaconda API. Please run `conda install anaconda-client`."
            )
            return False
        return self.package is not None and self.valid_package()
    return False