pipdeptree icon indicating copy to clipboard operation
pipdeptree copied to clipboard

Output redirection raise BrokenPipeError

Open wkschwartz opened this issue 5 years ago • 2 comments

On macOS 10.13 and Python 3.7.1, the code in the README does not work.

~/Documents $ mkdir pipdeptree
~/Documents $ cd pipdeptree/
~/Documents/pipdeptree $ python3 -m venv venv
~/Documents/pipdeptree $ source venv/bin/activate
(venv) ~/Documents/pipdeptree $ pip install pipdeptree
Collecting pipdeptree
  Using cached https://files.pythonhosted.org/packages/<hash omitted>/pipdeptree-0.13.1-py3-none-any.whl
Requirement already satisfied: pip>=6.0.0 in ./venv/lib/python3.7/site-packages (from pipdeptree) (10.0.1)
Installing collected packages: pipdeptree
Successfully installed pipdeptree-0.13.1
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) ~/Documents/pipdeptree $ pipdeptree -f --warn silence | grep -P '^[\w0-9\-=.]+'
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

wkschwartz avatar Dec 06 '18 17:12 wkschwartz

I think the problem here is that grep on OSX (BSD) doesn't support the --perl-regexp or -P flag. You might be able to get it working with the --extended-regexp or -E. Otherwise you can install GNU grep on Mac.

naiquevin avatar Dec 07 '18 09:12 naiquevin

On a Mac this works instead: pipdeptree -f --warn silence | grep -v '[[:space:]]'

Maybe this can be added to the docs for convenience?

JamieMartin avatar Jun 03 '19 15:06 JamieMartin

I think this is no longer the case.

gaborbernat avatar Sep 06 '22 07:09 gaborbernat