# Buggy code
def from_file(filename):
    url_scheme = filename.split("://", 1)[0]
    if url_scheme in CONDA_SESSION_SCHEMES:
        yamlstr = download_text(filename)
    elif not os.path.exists(filename):
        raise exceptions.EnvironmentFileNotFound(filename)
    else:
        with open(filename, "r") as fp:
            yamlstr = fp.read()
    return from_yaml(yamlstr, filename=filename)


# Traceback (ruamel_yaml.reader.ReaderError)
DEBUG conda.gateways.logging:set_verbosity(231): verbosity set to 3

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

Traceback (most recent call last):
File "D:\Program_Files\miniconda3\lib\site-packages\conda\exceptions.py", line 1079, in __call__
return func(*args, **kwargs)
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\cli\main.py", line 80, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\cli\main_create.py", line 80, in execute
directory=os.getcwd())
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\specs\__init__.py", line 40, in detect
if spec.can_handle():
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\specs\yaml_file.py", line 18, in can_handle
self._environment = env.from_file(self.filename)
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\env.py", line 151, in from_file
return from_yaml(yamlstr, filename=filename)
File "D:\Program_Files\miniconda3\lib\site-packages\conda_env\env.py", line 136, in from_yaml
data = yaml_load_standard(yamlstr)
File "D:\Program_Files\miniconda3\lib\site-packages\conda\common\serialize.py", line 76, in yaml_load_standard
return yaml.load(string, Loader=yaml.Loader, version="1.2")
File "D:\Program_Files\miniconda3\lib\site-packages\ruamel_yaml\main.py", line 933, in load
loader = Loader(stream, version, preserve_quotes=preserve_quotes)
File "D:\Program_Files\miniconda3\lib\site-packages\ruamel_yaml\loader.py", line 50, in __init__
Reader.__init__(self, stream, loader=self)
File "D:\Program_Files\miniconda3\lib\site-packages\ruamel_yaml\reader.py", line 85, in __init__
self.stream = stream  # type: Any  # as .read is called
File "D:\Program_Files\miniconda3\lib\site-packages\ruamel_yaml\reader.py", line 117, in stream
self.check_printable(val)
File "D:\Program_Files\miniconda3\lib\site-packages\ruamel_yaml\reader.py", line 255, in check_printable
'special characters are not allowed',
ruamel_yaml.reader.ReaderError: unacceptable character #x0000: special characters are not allowed
in "<unicode string>", position 3

`$ D:\Program_Files\miniconda3\Scripts\conda-env-script.py create -v -v -v -f .\environment.yml`

environment variables:
CIO_TEST=<not set>
CONDA_AUTO_UPDATE_CONDA=false
CONDA_DEFAULT_ENV=base
CONDA_EXE=D:\Program_Files\miniconda3\Scripts\conda.exe
CONDA_PREFIX=D:\Program_Files\miniconda3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=D:\Program_Files\miniconda3\python.exe
CONDA_ROOT=D:\Program_Files\miniconda3
CONDA_SHLVL=1
HOMEPATH=\
PATH=D:\Program_Files\miniconda3;D:\Program_Files\miniconda3\Library\mingw-
w64\bin;D:\Program_Files\miniconda3\Library\usr\bin;D:\Program_Files\m
iniconda3\Library\bin;D:\Program_Files\miniconda3\Scripts;D:\Program_F
iles\miniconda3\bin;D:\Program_Files\miniconda3;D:\Program_Files\minic
onda3\Library\mingw-w64\bin;D:\Program_Files\miniconda3\Library\usr\bi
n;D:\Program_Files\miniconda3\Library\bin;D:\Program_Files\miniconda3\
Scripts;D:\Program_Files\miniconda3\bin;D:\Program_Files\miniconda3\co
ndabin;C:\Oracle11\Ora11G-64\11.2.0\client_1\bin;C:\Oracle\ORA11\11.2.
0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDO
WS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Prog
ram Files (x86)\WebEx\Productivity Tools;C:\Program
Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL
Server\150\DTS\Binn;C:\Program Files (x86)\ArcGIS\Bin;C:\Program Files
(x86)\ArcGIS\EsriProductionMapping\Desktop10.5\Bin;C:\Program
Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Webe
x\Webex\Applications;C:\Users\avitale\AppData\Local\Microsoft\WindowsA
pps;C:\Users\avitale\AppData\Local\Programs\Microsoft VS Code\bin;C:\U
sers\avitale\AppData\Roaming\npm;C:\Python3X;C:\OSGeo4W\bin;C:\Python3
X;C:\OSGeo4W\bin;C:\Python3X;C:\OSGeo4W\bin;C:\OSGeo4W\bin;C:\Program
Files\dotnet;C:\Users\avitale\AppData\Local\Microsoft\WindowsApps;.;C:
\Users\avitale\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\a
vitale\AppData\Roaming\npm;C:\Users\avitale\.dotnet\tools
PSMODULEPATH=C:\Users\avitale\Documents\WindowsPowerShell\Modules;C:\Program Files\
WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\M
odules
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>

active environment : base
active env location : D:\Program_Files\miniconda3
shell level : 1
user config file : C:\Users\avitale\.condarc
populated config files : C:\Users\avitale\.condarc
conda version : 4.8.2
conda-build version : not installed
python version : 3.7.4.final.0
virtual packages : __cuda=10.2
base environment : D:\Program_Files\miniconda3  (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : D:\Program_Files\miniconda3\pkgs
C:\Users\avitale\.conda\pkgs
C:\Users\avitale\AppData\Local\conda\conda\pkgs
envs directories : D:\Program_Files\miniconda3\envs
C:\Users\avitale\.conda\envs
C:\Users\avitale\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.4 Windows/10 Windows/10.0.17134
administrator : False
netrc file : None
offline mode : False


An unexpected error has occurred. Conda has prepared the above report.

If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?

[y/N]:

No report sent. To permanently opt-out, use

$ conda config --set report_errors false

# Fixed code
def from_file(filename):
    url_scheme = filename.split("://", 1)[0]
    if url_scheme in CONDA_SESSION_SCHEMES:
        yamlstr = download_text(filename)
    elif not os.path.exists(filename):
        raise exceptions.EnvironmentFileNotFound(filename)
    else:
        with open(filename, "rb") as fp:
            yamlb = fp.read()
            try:
                yamlstr = yamlb.decode("utf-8")
            except UnicodeDecodeError:
                yamlstr = yamlb.decode("utf-16")
    return from_yaml(yamlstr, filename=filename)