I have a Python virtual environment named venv
in the user home directory. I would like to activate this virtual environment on login. I don't want to type source venv/bin/activate
each time after login. I want to type python something.py
and have it always use the virtual environment.
How can I do this in the user's login scripts?
The user is only ever going to do python development in this particular virtual environment.
CodePudding user response:
There might be better ways of doing this but the simplest way I can think of is modifying .bashrc file if you are using an OS Like Ubuntu. In your .bashrc file you can add a line to start your virtual environment. An example could be adding the following to the bottom of your .bashrc file:
source myvenv/bin/activate