deactivate conflict in virtualenvwapper and anaconda

前端 未结 5 734
春和景丽
春和景丽 2020-12-29 10:35

I\'m using virtualenv to switch my python dev env. But when I run workon my_env, I meet such error message:

Error: deactivate must be sourced. R         


        
5条回答
  •  隐瞒了意图╮
    2020-12-29 11:06

    As I do not have enough reputations to add a comment: Thomas Capote's suggestion is fine (thx 4 that), except "zsh" does not have a "-t" option for the build-in command "type". Therefore its necessary to add another conditional statement to get desired result for "nametype":

    # Anaconda workaround for "source deactivate" message:
    # Start of workaround:
    #type deactivate >/dev/null 2>&1
    #if [ $? -eq 0 ]
    if [ -n $ZSH_VERSION ] ; then
        nametype="$(type -w deactivate)"
    else
        nametype="$(type -t deactivate)"
    fi
    if [ "${nametype##* }" == "function" ]
    # End of workaround
    

    Hope it helps other zsh users.

提交回复
热议问题