Forums

Custom console virtualenv

Is it possible to create a custom console that starts with one of my virtualenvs? Somehow workon doesn't work on custom console

We do it using a bit of a horrible hack, maybe you can find one too.... Here's a starting point, try a custom console with this as the command:

bash --rcfile ~/.virtualenvs/my-virtualenv/bin/activate -i

Thanks for the help! Any hints on how to them start the python interpreter automatically, I tried the two commands on the same line and with a bash script to no avail.

Oh, if you just want to run python, then just point at the virtualenv version of python:

~/.virtualenvs/my-virtualenv/bin/python

Thanks, I had just figured it out right this minute. Congratulations on the platform.

This was very helpful, but how do I get the prompt to reflect the regular prompt in my other consoles?

I think there's actually a better way to start a custom console in a virtualenv now that there was when this forum thread was started. Try using this command instead of the one above, and it should include your .bashrc as well as the virtualenv activate script, so you'll get your prompt:

launch_bash_in_virtualenv.py $(dbus-uuidgen) ~/.virtualenvs/my-virtualenv/ ~

The last parameter is the working directory where the console will start, so you can change that too if you want to customize that.

Perfect. Thanks, Giles.

it worked like a charm for me ;) Thanks, Giles

Excellent, thanks for confirming :-)