22 April 2013

Cannot find virtualenvwrapper_lazy.sh

An update has been posted to this over here

zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with `pip install virtualenvwrapper`.

I've seen this error on a new VM one too many times now, so here's the hack that I use to fix it. I can't even remember where I stole/adapted this from anymore.

Create a new file at /usr/local/bin/virtualenvwrapper_lazy.sh, with the following content:

#!/bin/bash
# Alternative startup script for faster login times.

export _VIRTUALENVWRAPPER_API="mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv"

if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
then
    export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)"
fi
if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
then
    echo "ERROR: virtualenvwrapper_quick.sh: Could not find virtualenvwrapper.sh" 1>&2
fi

# Load the real implementation of the API from virtualenvwrapper.sh
function virtualenvwrapper_load {
    source "$VIRTUALENVWRAPPER_SCRIPT"
}

# Set up "alias" functions based on the API definition.
function virtualenvwrapper_setup_lazy_loader {
    typeset venvw_name
    for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API})
    do
        eval "
function $venvw_name {
    virtualenvwrapper_load
    ${venvw_name} \"\$@\"
}
"
    done
}

virtualenvwrapper_setup_lazy_loader

Make sure that it's executable by all:

sudo chmod 755 /usr/local/bin/virtualenvwrapper_lazy.sh

:x


Tagged in tekkers python