zsh file exists error on new package installation with pip

1k views Asked by At

I am on mac, and have set up zsh with prezto on terminal. I have a python project for which I use virtualenv wrapper. Everything is working fine, but when I install a new package using pip and wants to freeze it in already existing requirements.txt file, zsh says:

zsh: file exists: requirements

The command which I run is : pip freeze > requirements.txt My zshrc file is as follows:

if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi

# Customize to your needs...
export PATH=$PATH:$HOME/bin


ZSH_THEME="steeef"

plugins=(git django colored-man themes colorize github jira vagrant virtualenvwrapper pip python brew osx zsh-syntax-highlighting history-substring-search)

# export WORKON_HOME=$HOME/.virtuale    nvs
# source /usr/local/bin/virtualenvwrapper.sh

export PATH=$PATH:/usr/local/mysql/bin

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
PATH=$PATH:~/bin
export PATH
# source ~/.bash_profile
# export M2_HOME=~/maven-3.3.9
# export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=
source /usr/local/bin/virtualenvwrapper.sh
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.6/bin
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

May I know what is possibly wrong here?

Thanks

1

There are 1 answers

1
Inian On BEST ANSWER

It is likely because of your CLOBBER option in zsh shell

CLOBBER (+C, ksh: +C) <D>
Allows ‘>’ redirection to truncate existing files. Otherwise ‘>!’ or ‘>|’ must be used to
truncate a file.

If the option is not set, and the option APPEND_CREATE is also not set, ‘>>!’ or ‘>>|’ must be used to create a file. If either option is set, ‘>>’ may be used.

So just add a line in your .zshrc to take it effect on all your sessions.

setopt clobber

(or) do a clobber on re-direction to as pip freeze >! requirements.txt

>! word
Same as >, except that the file is truncated to zero length if it exists, even if 
CLOBBER is unset.