When I want to work on a virtual environment with virtualenv(1.8.2) and virtualenvwrapper(3.6) I just run workon my_project. I am however unable to execute a command from a virtual environment using crontab or gnome-terminal:
Examples:
* * * * * workon my_project && python task.py
This is’nt executed. (The task writes to a file)
or
gnome-terminal --tab -e "bash -c \"workon my_project;python task.py;exec bash\""
This just shows bash: workon: command not found and then executes the program from the system environment. Check here for more info about this command.
Edit
@Zaar Hai: To initiate virtualenvwrapper this in my /home/myusername/.bashrc:
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
So I tried this command:
gnome-terminal --tab -e "bash -c \"export WORKON_HOME=~/.virtualenvs;source /usr/local/bin/virtualenvwrapper.sh;export PIP_VIRTUALENV_BASE=$WORKON_HOME;export PIP_RESPECT_VIRTUALENV=true;source /home/myusername/.virtualenvs/my_project/bin/activate;exec bash\""
But I still get that same output as I posted in your comment.
Through crontab:
Through gnome terminal:
Better of all just create a runme.sh script:
And run this script through gnome terminal / crontab.