I have a Django project running in a virtualenv and I would like the terminal to run in that virtualenv when opened. At the moment I have to type workon virtualenv
which isn't exactly the end of the world but I'm guessing there is a way to make this happen automatically?
Is there a way to run commands at startup like you can do with the django and python consoles?
Asked
Active
Viewed 1,673 times
3

eggbert
- 3,105
- 5
- 30
- 39
-
are you on os x, windows or some linux? – tttthomasssss Oct 15 '14 at 15:11
-
Have you considered changing the path to the Python interpreter to the interpreter inside your virtualenv directory? – schillingt Oct 15 '14 at 15:49
-
@tttthomasssss: linux – eggbert Oct 15 '14 at 21:20
-
@schillingt: I already have – eggbert Oct 15 '14 at 21:21
-
@eggbert try the answer to this post: http://stackoverflow.com/questions/22288569/how-do-i-activate-a-virtualenv-inside-pycharms-terminal – tttthomasssss Oct 15 '14 at 21:24
2 Answers
2
As tttthomasssss suggested, the answer is here: https://stackoverflow.com/a/22289136/519074. Only this answer worked, the ones below it didn't even though they look more useful.
Update - This is what worked for me:
For each virtualenv, put a file called something like terminalactivate.sh into /bin with this:
#!/bin/sh
source ~/.bashrc
source $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/activate
Then in pycharm/idea settings choose this for shell path:
/bin/bash --rcfile ~/virtualenv/sff/bin/terminalactivate.sh
0
I know this is a very old question, but if you're using fish shell, you can also do this with the -C flag. For example I use it to set a different theme on shells open inside intellij by setting shell path to:
/opt/homebrew/bin/fish -C "fish_config theme choose 'Solarized Light'"

Damian Pereira
- 23
- 4