我需要编写一个脚本来启动使用 pyenv 开发的gunicorn + django 站点,该脚本类似于
#!/bin/bash
pyenv activate .ve
pyenv exec gunicorn config.wsgi:application --name mini2 --workers 8 \
--workers 8 --bind=unix:/tmp/run/mini2.socket \
--log-level=debug --log-file=-
Run Code Online (Sandbox Code Playgroud)
和错误消息
2021-12-06 14:09:00 [mini2@s017 mini2]$ ./prodution.sh
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
2021-12-06 14:09:55 [mini2@s017 mini2]$
Run Code Online (Sandbox Code Playgroud)
我可以逐行运行脚本。所以脚本中肯定有问题,但我不知道出了什么问题。
我已经在 bashrc 中附加了几行关于 pyenv 的内容
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
Run Code Online (Sandbox Code Playgroud)
那么有没有办法在bash脚本中激活pyenv创建的virtualenv?有什么建议 ?? …