使用 pip 安装新包时 zsh 文件存在错误
zsh file exists error on new package installation with pip
我在 mac,并在终端上用 prezto 设置了 zsh。
我有一个使用 virtualenv 包装器的 python 项目。一切正常,但是当我使用 pip 安装新包并想将其冻结在现有的 requirements.txt 文件中时,zsh 说:
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"
我可以知道这里可能出了什么问题吗?
谢谢
这可能是因为您在 zsh
shell
中的 CLOBBER
选项
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.
所以只需在您的 .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.
我在 mac,并在终端上用 prezto 设置了 zsh。 我有一个使用 virtualenv 包装器的 python 项目。一切正常,但是当我使用 pip 安装新包并想将其冻结在现有的 requirements.txt 文件中时,zsh 说:
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"
我可以知道这里可能出了什么问题吗?
谢谢
这可能是因为您在 zsh
shell
CLOBBER
选项
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.
所以只需在您的 .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.