PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement (local module)
Unable to switch from AWS Layer to specifying locally built editable pip3 packages when executing function:
I'm both learning python and attempting to build multiple lambdas that will both store and process Spotify listening history. I originally wrote one lambda with all dependencies packaged in the same directory and imported using relative paths.
Once creating similar functions which use the same dependencies, I've split the dependencies from the function and built them using pip3 and setup.py. When running pip3 list I can see the packages as expected. To execute the function locally using sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json and verify success, I'm specifying a layer I've built - this works!
To avoid having to rebuild the layer and modifying my function, I'd like to be able to revert to using a requirements.txt file and removing the specified layer.
Steps to reproduce the issue:
- Build local editable package -
pip3 install -e . - Specify in requirements.txt
sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json
Observed result:
Building resource 'SpotifyPlayHistoryListener'
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: spotify-client
Expected result:
Build succeeds and function executes successfully.
Additional environment details:
I'm able to execute the function locally using sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json when specfying dependencies using a Layer
I'm open to being told I'm completely off the mark here. Though I feel like I'm not a million miles away.
**Duplicate of: ** https://github.com/awslabs/aws-lambda-builders/issues/155 (Unsure which repository this belongs under)
How have you specified your dependency in requirements.txt
Hey @sriram-mv ,
The dependency is defined as:
spotify-client==0.0.1
The output from pip3 list is:
...
...
spotify 0.4.8
spotify-client 0.0.1 /Repositories/Personal/Spotify/SpotifyAPIClient
...
The folder directory looks like:
.
├── README.md
├── env.json
├── events
│ └── event.json
├── packaged.yaml
├── spotify_play_history_listener
│ ├── __init__.py
│ ├── app.py
│ ├── requirements.txt
├── template.yaml
Any guidance would greatly appreciated :)
if spotify-client is from a local file system and not a package published to pypi, it needs the actual path there.
@sriram-mv Thank you! Building and running successfully.
I am facing the same issue. I specified the full file path to the local module (named shared_code in my requirements.txt, but I am getting aws_lambda_builders.workflows.python_pip.packager.UnsupportedPackageError: Unable to retrieve name/version for package: shared-code