python - Piping explicit conda list -
i need pipe conda commands:
$ conda list --export | head -n 3 # file may used create environment using: # $ conda create --name <env> --file <this file> # platform: linux-64
this works fine. piping explicit list fails:
$ conda list --explicit | head -n 3 # file may used create environment using: # $ conda create --name <env> --file <this file> # platform: linux-64 unexpected error has occurred. please consider posting following information conda github issue tracker at: https://github.com/conda/conda/issues current conda install: platform : linux-64 conda version : 4.2.12 conda private : false conda-env version : 4.2.12 conda-build version : not installed python version : 2.7.12.final.0 requests version : 2.11.1 root environment : /home/me/miniconda3 (writable) default environment : /home/me/miniconda3 envs directories : /home/me/miniconda3/envs package cache : /home/me/miniconda3/pkgs channel urls : https://repo.continuum.io/pkgs/free/linux-64 https://repo.continuum.io/pkgs/free/noarch https://repo.continuum.io/pkgs/pro/linux-64 https://repo.continuum.io/pkgs/pro/noarch config file : none offline mode : false `$ /home/me/miniconda3/bin/conda list --explicit`
the traceback (sorry, wont allow me put inside code tags...):
traceback (most recent call last): file "/home/me/miniconda3/lib/python2.7/site-packages/conda/exceptions.py", line 479, in conda_exception_handler return_value = func(*args, **kwargs) file "/home/me/miniconda3/lib/python2.7/site-packages/conda/cli/main.py", line 145, in _main exit_code = args.func(args, p) file "/home/me/miniconda3/lib/python2.7/site-packages/conda/cli/main_list.py", line 213, in execute print_explicit(prefix, args.md5) file "/home/me/miniconda3/lib/python2.7/site-packages/conda/cli/main_list.py", line 190, in print_explicit print(url + ('#%s' % md5 if add_md5 , md5 else '')) ioerror: [errno 32] broken pipe
that's bug right? without piping works fine.
the broken pipe occurring because head
closing output stream once gets 3 lines has been instructed show. you'll notice 3 lines in output. next time conda tries print, cannot because head
has closed pipe. causing exception. not problem conda. have here further information regarding broken pipe exceptions in python: ioerror: [errno 32] broken pipe: python
now potential work around:
$ conda list --explicit > /tmp/conda-explicit-output && head -n 15 /tmp/conda-explicit-output && rm /tmp/conda-explicit-output
yeah it's pretty ugly, job done.
Comments
Post a Comment