Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zappa init error: "Zappa requires an active virtual environment" #1030

Closed
georgymh opened this issue Aug 3, 2017 · 4 comments
Closed

zappa init error: "Zappa requires an active virtual environment" #1030

georgymh opened this issue Aug 3, 2017 · 4 comments

Comments

@georgymh
Copy link

georgymh commented Aug 3, 2017

Hi, I try running zappa init inside a virtualenv p36 (created doing virtualenv --python=python3.6 p36) but I get the following error:

click.exceptions.ClickException: Zappa requires an active virtual environment!

Any ideas why? I just want to make flask-ask work in a Lambda Function :)

Full traceback down below:

(p36) mac:alexa georgymh$ zappa init
Oh no! An error occurred! :(

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

Traceback (most recent call last):


#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Zappa CLI

Deploy arbitrary Python programs as serverless Zappa applications.

"""

from __future__ import unicode_literals
from __future__ import division
from past.builtins import basestring
from builtins import input, bytes

import argcomplete
import argparse
import base64
import pkgutil
import botocore
import click
import collections
import hjson as json
import inspect
:2453
    def check_venv(self):
  File "/Users/georgymh/Documents/Development/Projects/alexa/p36/lib/python3.6/site-packages/zappa/cli.py", line 2489, in handle
    sys.exit(cli.handle())
  File "/Users/georgymh/Documents/Development/Projects/alexa/p36/lib/python3.6/site-packages/zappa/cli.py", line 444, in handle
    self.init()
  File "/Users/georgymh/Documents/Development/Projects/alexa/p36/lib/python3.6/site-packages/zappa/cli.py", line 1394, in init
    self.check_venv()
  File "/Users/georgymh/Documents/Development/Projects/alexa/p36/lib/python3.6/site-packages/zappa/cli.py", line 2453, 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/

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

Need help? Found a bug? Let us know! :D
File bug reports on GitHub here: https://github.com/Miserlou/Zappa
And join our Slack channel here: https://slack.zappa.io
Love!,
 ~ Team Zappa!
@georgymh georgymh changed the title zappa init with virtualenv error zappa init error: "Zappa requires an active virtual environment" Aug 3, 2017
@georgymh
Copy link
Author

georgymh commented Aug 3, 2017

Found a hacky, temporary workaround:

  1. Comment out the lines in your virtualenv's site-packages/zappa/cli.py where it throws an exception when the venv is not found (around line 2453 in the current version).

  2. Run export VIRTUAL_ENV=<your virtual environment path> so that site-packages/zappa/core.py doesn't error. Example: export VIRTUAL_ENV=/Users/georgymh/Documents/Development/Projects/alexa/p36.

  3. Run zappa init and zappa deploy dev as initially intended.

(I have a feeling the first step is redundant, but I haven't tried doing step 3 without step 1 yet.)

@zaraken
Copy link

zaraken commented Aug 3, 2017

This seems more like a virtual environment problem, rather than zappa error.
You should not need to to set VIRTUAL_ENV manually. Could you check the value of VIRTUAL_ENV after activating your virtual environment via: source /path_to_your_venv/bin/activate

@georgymh
Copy link
Author

georgymh commented Aug 4, 2017

Thanks @zaraken. That was the problem.

So I was doing source activate, but it doesn't set the VIRTUAL_ENV environmental variable. (I wonder why?)

When I do source /path/to/venv/bin/activate, however, it does set it. I'm almost certain this would have made Zappa work correctly in the first place.

Closing the issue.

@rajacsp
Copy link

rajacsp commented Dec 28, 2020

I have faced the same issue when I used Conda environment. Then I switched to virtualenv and it worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants