question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI not compatible with Python 3+

See original GitHub issue

Getting a syntax error when I try to run the CLI commands. The print statement in the CLI init.py file doesn’t have parentheses:

    print event['timestamp'], event['logShortId'], event['message'].strip()
         ^
SyntaxError: invalid syntax

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
jameslscommented, Jul 11, 2016

The intent is for chalice to support the same versions of python that AWS Lambda supports, which is currently python 2.7. So while possible to make it work, it could be confusing to work on your app in python3, but only to have it fail when deploying to lambda.

The more technical reason why supporting python3 is challenging in chalice is because chalice introspects your source code in order to configure things automatically for you, including importing your app.py file so we can iterate through all your @app.route declarations and parsing your app source code using the ast and symtable module for policy generation. So even if the chalice code base worked in python2/python3, the minute we try to import your app, and your app happens to have a "print 'foo'" statement in it, it’ll fail.

1reaction
nealmcbcommented, Mar 22, 2017

It is hard to believe that Amazon’s premier entry in the hot “serverless” space still only supports the dying technology of Python 2. For those that haven’t looked in recent years, support for Python 2 is due to end in 2020. Ubuntu doesn’t even install it by default. A summary of the situation (with a nice graphical timeline showing nearly all other enviroments already ported to Python 3) is at http://www.python3statement.org/

Please reopen this bug until Chalice at least provides better support for projects that are trying to ensure Python 3 compatibility, i.e. having code that can be imported into a python 3 code base.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CLI not working because of unsupported Python version
The issue I'm having is that aliasing python to python3 isn't working. For some reason, after aliasing, the installer still references Python ......
Read more >
4. Using Python on Windows — Python 3.11.1 documentation
This document aims to give an overview of Windows-specific behaviour you should know about when using Python on Microsoft Windows. Unlike most Unix...
Read more >
The AWS CLI and AWS SDK for Python will require Python 2.7 ...
I'm currently using Python 2.6 or Python 3.3 as my runtime for AWS CLI or AWS SDK for Python. What should I do?...
Read more >
Support for Python 3 · Issue #1337 · nodejs/node-gyp - GitHub
I have had python 3 installed forever and do not want python 2 as it can cause havoc to have both installed as...
Read more >
Python 3 Support — Click Documentation (7.x)
Click supports Python 3, but like all other command line utility ... For more information see Python 3 Surrogate Handling. ... This is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found