Open peterharmazinski opened 7 years ago
This is a Windows-specific bug. 0.41.2 may have it fixed?
Hi,
I get the same error using
Windows 7 Python 3.5.2 zappa 0.41.3
The app I use is saved in UTF-8 encoding,
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, from Zappa!\n'
if __name__ == '__main__':
app.run()
I get the following error running zappa init
:
It looks like this is a Flask application.
Oh no! An error occurred! :(
==============
Traceback (most recent call last):
File "c:\users\z003kb2p\appdata\local\continuum\anaconda3\lib\site-packages\za
ppa\cli.py", line 2353, in handle
sys.exit(cli.handle())
File "c:\users\z003kb2p\appdata\local\continuum\anaconda3\lib\site-packages\za
ppa\cli.py", line 427, in handle
self.init()
File "c:\users\z003kb2p\appdata\local\continuum\anaconda3\lib\site-packages\za
ppa\cli.py", line 1384, in init
matches = detect_flask_apps()
File "c:\users\z003kb2p\appdata\local\continuum\anaconda3\lib\site-packages\za
ppa\utilities.py", line 143, in detect_flask_apps
lines = f.readlines()
File "c:\users\z003kb2p\appdata\local\continuum\anaconda3\lib\encodings\cp1252
.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 301: char
acter maps to <undefined>
==============
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!
So, doesn't look like it was fixed in 0.41.2 :-(
Can't repro and I don't have a windows machine to test on. Could be fixed by adding the coding header to files maybe?
I am getting exactly the same error.
Windows 10 Python 3.6 Zappa 0.42.0
So apparently Zappa scans the files in the project folder for flask apps. So if your virtualenv folder is in your project folder just move it outside of it. That did it for me
I'm getting this error. Windows 10 Python 3.6 Zappa 0.42.0
My virtual environment folder is not in my project folder, so mcdallas's solution can't fix my issue.
==============
Traceback (most recent call last): File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\zappa\cli.py", line 2353, in handle sys.exit(cli.handle()) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\zappa\cli.py", line 427, in handle self.init() File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\zappa\cli.py", line 1284, in init \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d\n""", fg='green', bold=True)) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\click\utils.py", line 259, in echo file.write(message) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\colorama\ansitowin32.py", line 40, in write self.__convertor.write(text) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\colorama\ansitowin32.py", line 141, in write self.write_and_convert(text) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\colorama\ansitowin32.py", line 169, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\site-packages\colorama\ansitowin32.py", line 174, in write_plain_text self.wrapped.write(text[start:end]) File "c:\users\v-jamisc.virtualenvs\alexa-color\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 2-9: character maps to
==============
I had the same problem, and now is solved, what I did was: opened the file utilities.py and search for the code with open(full, 'r') as f: and update it to be with open(full, 'r', encoding="utf8") as f: I mean only add encoding="utf8"
Actually it's the files called "utilities.py" that is where I made the change.. Line 142
with open(full, 'r', encoding="utf8") as f:
Hello folks, I just had the same issue and traced it back to zappa/cli.py line 1499 and found a funny suprise :
Looks like the fancy ZAPPA header has some decoding problems with c1252 codec. Replacing it by a simple text solved the issue for me. (Running zappa 0.45.1)
EDIT : I got the error again and this time could solved it with kram66 solution.
I think I'm on track regarding this bug.
Many times failing to execute zappa init
it looks like it's only failing when flask is already installed in the actual environment.
How to avoid this bug:
$ virtualenv env
$ .\env\Scripts\activate
$ pip install zappa
$ zappa init
$ pip install flask
$ zappa deploy dev
Hope it helps.
Looks like there's a workaround (regardless Python & Windows).
I got the same error too. I am using the virtual environment on windows10, python3.6 and Zappa0.46.1 Also, in utilities.py, it was updated to io.open(full, 'r', encoding='utf-8') as f but I got same error. Traceback (most recent call last): File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\zappa\cli.py", line 2693, in handle sys.exit(cli.handle()) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\zappa\cli.py", line 475, in handle self.init() File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\zappa\cli.py", line 1546, in init \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d\n""", fg='green', bold=True)) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\click\utils.py", line 259, in echo file.write(message) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\colorama\ansitowin32.py", line 40, in write self.__convertor.write(text) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\colorama\ansitowin32.py", line 141, in write self.write_and_convert(text) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\colorama\ansitowin32.py", line 169, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "d:\python-aws-diy\repo_stats\venv\lib\site-packages\colorama\ansitowin32.py", line 174, in write_plain_text self.wrapped.write(text[start:end]) File "d:\python-aws-diy\repo_stats\venv\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 2-9: character maps to
Any help would be highly appreciated
I tried within python2.7 in virtualenv and I get the following error:
zappa init
███████╗ █████╗ ██████╗ ██████╗ █████╗ ╚══███╔╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗ ███╔╝ ███████║██████╔╝██████╔╝███████║ ███╔╝ ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██║ ███████╗██║ ██║██║ ██║ ██║ ██║ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝
Welcome to Zappa!
Zappa is a system for running server-less Python web applications on AWS Lambda and AWS API Gateway.
This init
command will help you create and configure your new Zappa deployment.
Let's get started!
Your Zappa configuration can support multiple production stages, like 'dev', 'staging', and 'production'. What do you want to call this environment (default 'dev'):
AWS Lambda and API Gateway are only available in certain regions. Let's check to make sure you have a profile set up in one that will work. Okay, using profile default!
Your Zappa deployments will need to be uploaded to a private S3 bucket. If you don't have a bucket yet, we'll create one for you too. What do you want to call your bucket? (default 'zappa-yczm78a40'):
It looks like this is a Flask application. Oh no! An error occurred! :(
==============
Traceback (most recent call last): File "d:\python-aws-diy\repo2.7\venv\lib\site-packages\zappa\cli.py", line 2693, in handle sys.exit(cli.handle()) File "d:\python-aws-diy\repo2.7\venv\lib\site-packages\zappa\cli.py", line 475, in handle self.init() File "d:\python-aws-diy\repo2.7\venv\lib\site-packages\zappa\cli.py", line 1646, in init matches = detect_flask_apps() File "d:\python-aws-diy\repo2.7\venv\lib\site-packages\zappa\utilities.py", line 148, in detect_flask_apps lines = f.readlines() File "d:\python-aws-diy\repo2.7\venv\lib\codecs.py", line 314, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf8' codec can't decode byte 0xf6 in position 117: invalid start byte
==============
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!
Just had this problem and built off of @Totalus suggestion of replacing the text with some safe text and made an MR for it.
Hi, I am using Mac OS X Python 3.7.2 Zappa 0.48.2
While errors are very similar as above listed the last line is this: File "/usr/local/bin/../Cellar/python/3.7.2_1/bin/../Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 80: invalid start byte
Working directory set up as python3 -m venv dirname.
I have tried above suggestions to fix this with no luck. Anyone has any other ways of solving this? Thanks!
Context
I read that Python 3 is now supported by AWS Lambda and Zappa, but when I try zappa init with default settings I get the below error: It looks like this is a Flask application. Oh no! An error occurred! :( ============== Traceback (most recent call last): File "c:\users\pharm\documents\alexa\repo_stats\venv\lib\site-packages\zappa\cli.py", line 2352, in handle sys.exit(cli.handle()) File "c:\users\pharm\documents\alexa\repo_stats\venv\lib\site-packages\zappa\cli.py", line 427, in handle self.init() File "c:\users\pharm\documents\alexa\repo_stats\venv\lib\site-packages\zappa\cli.py", line 1383, in init matches = detect_flask_apps() File "c:\users\pharm\documents\alexa\repo_stats\venv\lib\site-packages\zappa\utilities.py", line 143, in detect_flask_apps lines = f.readlines() File "c:\users\pharm\documents\alexa\repo_stats\venv\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps toActual Behavior
Possible Fix
Steps to Reproduce
Following this tutorial, but with Python 3: https://developer.amazon.com/blogs/post/8e8ad73a-99e9-4c0f-a7b3-60f92287b0bf/new-alexa-tutorial-deploy-flask-ask-skills-to-aws-lambda-with-zappa
Error occurs at zappa init with defaults selected
Your Environment
Windows 10 Python 3.6