3

My fabric file:

def deploy():
   code_path = 'mysite/public_html/mysite'
   with cd(code_path):
      with prefix("workon mysite"):
         run('git pull')
         run('supervisorctl -c ~/supervisord.conf restart ' + env.host_string)

I get the following error:

Aborting.
[myserv] out: /bin/bash: workon: command not found

Obviously workon command works when I do this manually (without fabric). I suspect /usr/local/bin/virtualenvwrapper.sh is not being sourced (it normally gets run through .bash_profile).

What do I need to do to get workon command working?

4

3 回答 3

7

尝试修改您的前缀:

  with prefix(". /usr/local/bin/virtualenvwrapper.sh; workon mysite"):
于 2013-08-28T06:35:20.120 回答
3

您必须将此虚拟包装器加载代码复制.bashrc.bash_profile文件中,或者如果不存在,则创建新.bash_profile文件并复制到那里。

要复制的代码::

export WORKON_HOME=/home/virtual
source /usr/local/bin/virtualenvwrapper.sh

发生此错误是因为.bashrc只能由交互式和非登录的 shell 读取。所以在这种情况下,它不是交互式非登录 shell,所以它不会工作。所以我们必须将这些代码复制到.bash_profile文件中。

参考链接

于 2016-12-10T13:44:02.277 回答
0

我将 pyenv 与插件 pyenv-virtualenvwrapper 一起使用。我的工作没有成功,而是使用这个(面料2.5):

with c.prefix('source /home/mirek/.virtualenvs/%s/bin/activate' % PROJECT):
    with c.prefix('cd /home/mirek/dj/%s/%s' % (PROJECT, PROJECT)):
        c.run('python manage.py ....')
于 2021-01-06T16:02:12.080 回答