aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement (local module)

Open michaelmelody91 opened this issue 6 years ago • 5 comments

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:

  1. Build local editable package - pip3 install -e .
  2. Specify in requirements.txt
  3. 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)

michaelmelody91 avatar Feb 11 '20 08:02 michaelmelody91

How have you specified your dependency in requirements.txt

sriram-mv avatar Feb 12 '20 18:02 sriram-mv

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 :)

michaelmelody91 avatar Feb 12 '20 19:02 michaelmelody91

if spotify-client is from a local file system and not a package published to pypi, it needs the actual path there.

sriram-mv avatar Feb 12 '20 22:02 sriram-mv

@sriram-mv Thank you! Building and running successfully.

michaelmelody91 avatar Feb 13 '20 08:02 michaelmelody91

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

heyitsmepatg avatar Feb 22 '23 18:02 heyitsmepatg