我试图在aws的ubuntu服务器上运行“ zappa init”,也安装了conda ....当我初始化zappa时,它要求“活动虚拟环境”

时间:2018-08-29 15:55:11

标签: zappa

哦,不!发生错误! :(

==============

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/zappa/cli.py", line 2693, in handle
    sys.exit(cli.handle())
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/zappa/cli.py", line 475, in handle
    self.init()
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/zappa/cli.py", line 1534, in init
    self.check_venv()
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/zappa/cli.py", line 2630, in check_venv
    "Learn more about virtual environments here: " + click.style("http://docs.python-guide.org/en/latest/dev/virtualenvs/", bold=False, fg="cyan"))
click.exceptions.ClickException: Zappa requires an active virtual environment!
Learn more about virtual environments here: http://docs.python-guide.org/en/latest/dev/virtualenvs/

==============

需要帮助吗?发现了错误?让我们知道! :D
在GitHub上提交错误报告:https://github.com/Miserlou/Zappa
并在此处加入我们的Slack频道:https://slack.zappa.io
爱!,〜Zappa队!

1 个答案:

答案 0 :(得分:1)

从回溯来看,似乎您没有在Zappa部署中使用虚拟环境。 Zappa需要一个虚拟环境,然后才能部署任何AWS Lambda软件包。

在此处详细了解如何创建虚拟环境:https://virtualenv.pypa.io/en/stable/

因此,基本上,必须在项目文件夹上运行:

(your project dir)$ pip install virtualenv
(your project dir)$ virtualenv venv
(your project dir)$ source venv/bin/activate
(your project dir)$ pip install requirements.txt
(your project dir)$ pip install zappa
(your project dir)$ zappa init
(your project dir)$ zappa deploy