Виртуальная среда Conda / проблема с сюжетом

#python #anaconda #yaml #conda

#python #анаконда #yaml #conda

Вопрос:

Я попытался создать следующую среду с помощью Anaconda Spyder:

 # -*- coding: utf-8 -*- 
name:env_dash 
dependencies:
    - python=3.8.3
    - pip
    - pip:
        - numpy==1.18.5
        - pandas==1.0.5
        - plotly==5.4.0
        - dash==2.0.0
        - gunicorn==20.1.0
 

Но когда я пытаюсь ее создать, я получаю сообщение об ошибке:

 (base) PS D:environments> conda env create -f Env_dash.yml

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

    Traceback (most recent call last):
      File "C:Usershugoaanaconda3libsite-packagescondaexceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "C:Usershugoaanaconda3libsite-packagesconda_envclimain.py", line 80, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:Usershugoaanaconda3libsite-packagesconda_envclimain_create.py", line 79, in execute
        spec = specs.detect(name=name, filename=expand(args.file),
      File "C:Usershugoaanaconda3libsite-packagesconda_envspecs__init__.py", line 40, in detect
        if spec.can_handle():
      File "C:Usershugoaanaconda3libsite-packagesconda_envspecsyaml_file.py", line 18, in can_handle
        self._environment = env.from_file(self.filename)
      File "C:Usershugoaanaconda3libsite-packagesconda_envenv.py", line 151, in from_file
        return from_yaml(yamlstr, filename=filename)
      File "C:Usershugoaanaconda3libsite-packagesconda_envenv.py", line 136, in from_yaml
        data = yaml_load_standard(yamlstr)
      File "C:Usershugoaanaconda3libsite-packagescondacommonserialize.py", line 76, in yaml_load_standard
        return yaml.load(string, Loader=yaml.Loader, version="1.2")
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlmain.py", line 935, in load
        return loader._constructor.get_single_data()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlconstructor.py", line 109, in get_single_data
        node = self.composer.get_single_node()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlcomposer.py", line 78, in get_single_node
        document = self.compose_document()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlcomposer.py", line 104, in compose_document
        self.parser.get_event()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlparser.py", line 163, in get_event
        self.current_event = self.state()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlparser.py", line 239, in parse_document_end
        token = self.scanner.peek_token()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlscanner.py", line 182, in peek_token
        self.fetch_more_tokens()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlscanner.py", line 282, in fetch_more_tokens
        return self.fetch_value()
      File "C:Usershugoaanaconda3libsite-packagesruamel_yamlscanner.py", line 651, in fetch_value
        raise ScannerError(
    ruamel_yaml.scanner.ScannerError: mapping values are not allowed here
      in "<unicode string>", line 3, column 13:
        dependencies:
                    ^ (line: 3)

$ C:Usershugoaanaconda3Scriptsconda-env-script.py create -f Env_dash.yml`

  environment variables:
                 CIO_TEST=<not set>   CONDA_AUTO_UPDATE_CONDA=false
        CONDA_DEFAULT_ENV=base
                CONDA_EXE=C:Usershugoaanaconda3Scriptsconda.exe
             CONDA_PREFIX=C:Usershugoaanaconda3
    CONDA_PROMPT_MODIFIER=(base)
         CONDA_PYTHON_EXE=C:Usershugoaanaconda3python.exe
               CONDA_ROOT=C:Usershugoaanaconda3
              CONDA_SHLVL=1
                 HOMEPATH=Usershugoa
                     PATH=C:Usershugoaanaconda3;C:Usershugoaanaconda3Librarymingw-w64bi
                          n;C:Usershugoaanaconda3Libraryusrbin;C:Usershugoaanaconda3Li
                          brarybin;C:Usershugoaanaconda3Scripts;C:Usershugoaanaconda3bi
                          n;C:Usershugoaanaconda3;C:Usershugoaanaconda3Librarymingw-w64
                          bin;C:Usershugoaanaconda3Libraryusrbin;C:Usershugoaanaconda3
                          Librarybin;C:Usershugoaanaconda3Scripts;C:Usershugoaanaconda3
                          bin;C:Usershugoaanaconda3condabin;C:Program Files (x86)Common
                          FilesOracleJavajavapath;C:Program Files (x86)InteliCLS
                          Client;C:Program FilesInteliCLS Client;C:WINDOWSsystem32;C:WINDO
                          WS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0
                          ;C:Program Files (x86)IntelIntel(R) Management Engine
                          ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine
                          ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine
                          ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine
                          ComponentsIPT;C:WINDOWSSystem32OpenSSH;C:Program Files
                          (x86)dotnet;C:Program FilesIntelWiFibin;C:Program FilesCommon F
                          ilesIntelWirelessCommon;C:UsershugoaAppDataLocalMicrosoftWindo
                          wsApps;D:Software-HugoMicrosoft VS Codebin;C:srcflutterbin;.
             PSMODULEPATH=C:UsershugoaDocumentsWindowsPowerShellModules;C:Program FilesWi
                          ndowsPowerShellModules;C:WINDOWSsystem32WindowsPowerShellv1.0Mod
                          ules
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
    VBOX_MSI_INSTALL_PATH=D:Virtual box

     active environment : base
    active env location : C:Usershugoaanaconda3
            shell level : 1
       user config file : C:Usershugoa.condarc  populated config files : C:Usershugoa.condarc
          conda version : 4.8.3
    conda-build version : 3.18.11
         python version : 3.8.3.final.0
       virtual packages :
       base environment : C:Usershugoaanaconda3  (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 : C:Usershugoaanaconda3pkgs
                          C:Usershugoa.condapkgs
                          C:UsershugoaAppDataLocalcondacondapkgs
       envs directories : C:Usershugoaanaconda3envs
                          C:Usershugoa.condaenvs
                          C:UsershugoaAppDataLocalcondacondaenvs
               platform : win-64
             user-agent : conda/4.8.3 requests/2.18.1 CPython/3.8.3 Windows/10 Windows/10.0.19041
          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.
 

Кто-нибудь решал это раньше?

Ответ №1:

Это похоже на проблему с форматированием YAML. Обратите внимание, что YAML чувствителен к пробелам. Для меня отлично работает следующее:

Env_dash.yaml

 # -*- coding: utf-8 -*- 
name: env_dash 
dependencies:
  - python=3.8.3
  - pip
  - pip:
    - numpy==1.18.5
    - pandas==1.0.5
    - plotly==5.4.0
    - dash==2.0.0
    - gunicorn==20.1.0
 

Пожалуйста, ознакомьтесь со спецификацией YAML. Также доступны онлайн-валидаторы.