2017-01-09 82 views
2

我在mac上,並在終端上設置了帶有prezto的zsh。 我有一個python項目,我使用virtualenv包裝。一切工作正常,但是當我安裝一個新的軟件包使用PIP,並希望它凍結在現有requirements.txt文件,zsh中說:zip文件在使用pip安裝新軟件包時存在錯誤

zsh: file exists: requirements 

我運行的命令是:pip freeze > requirements.txt 我zshrc文件如下:

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" 

我可以知道這裏可能有什麼問題嗎?

感謝

回答

2

這是因爲你的CLOBBER選項zsh殼的可能

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

如果選項未設置,選項APPEND_CREATE也沒有設置, '>>!'或'>> |'必須用於創建文件。如果設置了任一選項,則可以使用'>>'。

因此,只需在您的.zshrc中添加一行以使其對所有會話都有效。

setopt clobber 

(或)做re-direction一撞爲pip freeze >! requirements.txt

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

不是 「setopts揍」,而是 「SETOPT撞地」 爲我工作。 – Maverick

相關問題