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.

sam init errors with "No module named functools_lru_cache"

See original GitHub issue

Description:

Steps to reproduce the issue:

$ sam init

Observed result:

[+] Initializing project structure...
Error: An error ocurred while generating this sam-app: Unable to load extension: No module named functools_lru_cache

Expected result: It just works!™ Additional environment details (Ex: Windows, Mac, Amazon Linux etc) macOS 10.13.5 Output of sam --version: SAM CLI, version 0.3.0 Optional Debug logs:

$ sam init --debug
2018-06-11 19:49:22 Init command
[+] Initializing project structure...
2018-06-11 19:49:22 Parameters dict created with input given
2018-06-11 19:49:22 {'no_input': False, 'output_dir': '.', 'template': '/Users/anon/Library/Python/2.7/lib/python/site-packages/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs'}
2018-06-11 19:49:22 Parameters dict updated with project name as extra_context
2018-06-11 19:49:22 {'extra_context': {'project_name': u'sam-app', 'runtime': 'nodejs8.10'}, 'no_input': True, 'output_dir': '.', 'template': '/Users/anon/Library/Python/2.7/lib/python/site-packages/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs'}
2018-06-11 19:49:22 Baking a new template with cookiecutter with all parameters
2018-06-11 19:49:22 context_file is /Users/anon/Library/Python/2.7/lib/python/site-packages/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs/cookiecutter.json
2018-06-11 19:49:22 Context generated is {u'cookiecutter': OrderedDict([(u'project_name', u'sam-app'), (u'runtime', 'nodejs8.10')])}
Error: An error ocurred while generating this sam-app: Unable to load extension: No module named functools_lru_cache

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

16reactions
emilbryggarecommented, Jun 27, 2018

I had the same problem today. Resolved be uninstalling and installing backports.functools_lru_cache.

pip uninstall backports.functools_lru_cache pip install backports.functools_lru_cache

After this everything is working again.

10reactions
harpritcommented, Dec 16, 2018

The root cause seems that the functools_lru_cache related files were missing -

usr/lib/python2.7/dist-packages/backports$ ls
configparser  __init__.py  __init__.pyc

The above solution of uninstall/install didn’t work for me. matplotlib devs on Ubuntu were having same issue. Following their discussion, fixed the missing module issue with following command -

sudo apt-get install python-matplotlib

usr/lib/python2.7/dist-packages/backports$ ls
configparser functools_lru_cache.py  functools_lru_cache.pyc  __init__.py  __init__.pyc
Read more comments on GitHub >

github_iconTop Results From Across the Web

sam init errors with "No module named functools_lru_cache"
Description: Steps to reproduce the issue: $ sam init Observed result: [+] Initializing project structure... Error: An error ocurred while ...
Read more >
sam init - AWS Serverless Application Model
Initializes a serverless application with an AWS SAM template. ... If you're not sure, call sam init without options for an interactive workflow....
Read more >
Python not finding module when running AWS sam local invoke
SAM invoke can't seem to find a python module that my lambda handler is importing but I can otherwise import that module. The...
Read more >
Tutorial - AWS Lambda Powertools for Python
Tutorial. This tutorial progressively introduces Lambda Powertools core utilities by using one feature at a time.
Read more >
aws-sam-cli - AUR (en) - Arch Linux
Out of Date ... Git Clone URL: https://aur.archlinux.org/aws-sam-cli.git (read-only, ... Hitting a ModuleNotFoundError: No module named ...
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