Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call cdvirtualenv from a bash script?

The virtualenv package is set up from .bashrc by sourcing /usr/share.../virtualenvwrapper.sh. This file defines a number of functions, among those cdvirtualenv:

function cdvirtualenv {
    virtualenvwrapper_verify_workon_home || return 1
    virtualenvwrapper_verify_active_environment || return 1
    virtualenvwrapper_cd "$VIRTUAL_ENV/$1"
}

How do I call this function from my own script file?

Simply calling it:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#!/bin/bash

cdvirtualenv

gives me:

/srv/bin$ ./echotmp.sh
./echotmp.sh: line 3: cdvirtualenv: command not found

>Solution :

I hope this will help you, to call cdvirtualenv from a bash script, you can use the source command to execute the virtualenvwrapper.sh script and then call cdvirtualenv with the name of the virtual environment as an argument.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading