python import issues with serverless offline
See original GitHub issuegetting this error in project with both node and python functions & serverless-offline.
Traceback (most recent call last):
File "myproject/node_modules/serverless-offline/dist/lambda/handler-runner/python-runner/invoke.py", line 76, in <module>
module = import_module(args.handler_path.replace(os.sep, '.'))
File "/usr/lib64/python3.9/importlib/__init__.py", line 122, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '.esbuild..build.lambdas.tesseract'
I think its because the pre-offline.js
modifies the path for all functions. If I manually comment out pre-offline.js (code in the conditional) - then python functions start to work, but obviously that breaks all nodejs functions.
sls invoke local
works fine with both the python and node functions.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Import local modules Error when in higher folder using ...
Summary of Issue: We are using servereless frame work with runtime python3.7 we are using the plugin servereless-python-requirements.
Read more >Not working when using module in Python #1465 - GitHub
Bug Report Current Behavior When running sls offline and accessing the url I have the following error: Traceback (most recent call last): ...
Read more >Python serverless: ModuleNotFoundError - Stack Overflow
To run it, I use the command $ sls offline start Then When I query on postman http://localhost:3000/dev/hello I get the error ......
Read more >Serverless and Python: ''Unable to Import Module 'Handler'''
When writing serverless functions with Python, virtualenv users might hit a module/dependency-based error. Here's one library to get your ...
Read more >serverless-offline-python - npm package - Snyk
An important project maintenance signal to consider for serverless-offline-python is that it hasn't seen any new versions released to npm in the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is an issue actually with how serverless-offline loads python modules. https://github.com/dherault/serverless-offline/issues/993. I’ll see if I can add customisation options for where things get outputted in our repo
Thanks mate! I’m in the process of adding some integration tests so I’ll include something similar.