2016-11-10 37 views
0

我需要一些管道命令暢達:管道明確暢達列表

$ conda list --export | head -n 3 
# This file may be used to create an environment using: 
# $ conda create --name <env> --file <this file> 
# platform: linux-64 

這工作得很好。但是管道的明確列表失敗:

$ conda list --explicit | head -n 3 
# This file may be used to create an environment using: 
# $ conda create --name <env> --file <this file> 
# platform: linux-64 
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 : linux-64 
      conda version : 4.2.12 
     conda is 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` 

回溯的(對不起,它不會讓我把它裏面的代碼標籤...):

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 and md5 else '')) 

IOError: [Errno 32] Broken pipe 

這可能是一個錯誤嗎?沒有管道,它工作正常。

+0

我無法在Python 3的Ubuntu 16.04系統上重現此操作。您使用的是什麼操作系統? – darthbith

+0

我在mac osx上試過這個。我試着用linux – kaligne

+0

但是你的'conda info'顯示'linux-64'? FWIW,我也無法在OS X上重現這一點,但同樣,它的Miniconda 3 – darthbith

回答

1

由於head正在關閉輸出流,一旦它獲得了指示顯示的3行,就會發生斷管。你會注意到你的輸出中有三行。 conda下次嘗試打印時,它不能,因爲head已關閉管道。這是什麼導致這個例外。這不是conda的問題。有關於蟒蛇破管例外看看這裏瞭解更多信息:IOError: [Errno 32] Broken pipe: Python

現在對於一個潛在的解決方法:

$ conda list --explicit > /tmp/conda-explicit-output && head -n 15 /tmp/conda-explicit-output && rm /tmp/conda-explicit-output

沒錯這就是很醜陋,但它可能會完成這項工作。

+0

我想你解決了它!所以一般來說這不是一個管道問題。如果我做'$ conda list --explicit | wc -l'我得到'297'。所以現在:'$ conda list --explicit |頭-n 297'返回正確的結果。其實我用'head'來測試,本身並不需要它。所以我不需要「醜陋」的代碼;)THANKs! – kaligne