0

In my dev environment (ubuntu 16.04) I activated the venv for my first python project. Now every time I cd to its folder I can see, that it is activated.

foo@bar:~$ cd projects/my-project/
(my-project) foo@bar:~/projects/my-project$ cd ..
foo@bar:~/projects$

I deployed the project to a VPS (ubuntu 16.04), and now every time I connect to the server I have to re activate the venv, and the (venv) stays even I leave the folder.

ssh myvps
root@myvps:~# 
root@myvps:~# cd my-project/
root@myvps:~/my-project# source venv/bin/activate
(venv) root@myvps:~/my-project# cd ..
(venv) root@myvps:~# cd ..

Now on the vps int he project's folder there is a folder venv, but in my dev environment there is none.

How can I have the same behavior on the vps, that I dont have to activate the venv every time I connect to the server?

I am using pyenv in both environment.

user3568719
  • 1,036
  • 15
  • 33
  • you could always put a ```. ./venv/bin/activate``` in your .bashrc file (or whatever equivalent file is for your shell) – ewokx Jul 15 '20 at 08:44
  • 1
    The venv is deactivated because when you close your SSH connection, all the variables are reset, you can use a detached Tmux session or as @ewong suggested put the source command in a config file so that it's activated at each login. – RMPR Jul 15 '20 at 08:58
  • Maybe you are somehow using [_direnv_](https://pypi.org/project/direnv/) or something similar on your _dev_ environment, so that the _virtual environment_ is automatically activated when stepping into the directory. – sinoroc Jul 15 '20 at 09:34
  • 1
    standard method is to activate it manually and deactivate it manually, and it is deactivated when you close console/terminal - and this is what you have on server. In your system you may have extra program which activates it automatically when you enter folder. – furas Jul 15 '20 at 12:56

0 Answers0