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.

`ModuleNotFoundError` when locally invoking a python function

See original GitHub issue

In a project with both node and python functions, when you run serverless invoke local -f pythonFunction -d "{}" you receive a ModuleNotFoundError. If you comment out the serverless-esbuild plugin in the serverless.yml file it works.

I have attached an archive to reproduce the issue.

python-test.zip

Repro steps:

  • npm install
  • sls invoke local -f hello -d "{}"
  • This should complete successfully
  • sls invoke local -f world -d "{}"
  • This will fail with the ModuleNotFoundError
  • Comment out the serverless-esbuild plugin
  • sls invoke local -f world -d "{}"
  • This should complete successfully

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
shichongruicommented, Nov 24, 2021

Finally got some time to look into this again. I’ve tried the suggestion from https://github.com/floydspace/serverless-esbuild/issues/225#issuecomment-964850136 as well as the suggestions from the serverless docs and still am encountering the same issue and if I comment out the serverless-esbuild plugin, it works. I’ve included a zip file to hopefully be able to reproduce or tell me what I’m missing.

Here is my serverless.yml

service: hello-world
plugins:
  - serverless-esbuild
provider:
  name: aws
  runtime: nodejs14.x
package:
  individually: true
functions:
  hello:
    handler: index.handler
  world:
    handler: python.handler
    runtime: python3.8
    package:
      patterns:
        - '!**/*'
        - 'python.py'

python-test.zip

0reactions
github-actions[bot]commented, Dec 4, 2021

🎉 This issue has been resolved in version 1.22.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModuleNotFoundError: no module named Python Error [Fixed]
When you try to import a module in a Python file, Python tries to resolve this module in several ways. · As the...
Read more >
How to Fix ModuleNotFoundError and ImportError
first make sure you are using absolute imports · export the project's root directory to PYTHONPATH.
Read more >
"Module not found error" while trying to call a function that is in ...
Trying to call a function yamlCreation() which is in another directory into this python file .. the path of this file is.
Read more >
Python Import Error (ModuleNotFoundError) - Finxter
An ImportError is detected when Python has problems with a successful module import. Usually this problem is caused by the incorrect path and...
Read more >
`ModuleNotFoundError` when locally invoking a python function
In a project with both node and python functions, when you run serverless invoke local -f pythonFunction -d "{}" you receive a ModuleNotFoundError...
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