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.

PyCharm HelloWorld SAM Application Doesn't Build, Cannot Fetch Packages

See original GitHub issue

Description

SAM hello world function on PyCharm fails to build because of PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests

No package in requirements.txt seems to build.

Steps to reproduce

Create an AWS Serverless Applicatoin with the AWS SAM Hello World template in PyCharm 2019.3.2 with AWS Toolkit 1.10-93 and hit build.

Observed result

rick@Ricks-MacBook-Pro-2 AlkiFunction % /usr/local/bin/sam build --template /Users/rick/PycharmProjects/same_hello_world/template.yaml --build-dir /Users/rick/PycharmProjects/same_hello_world/.aws-sam/build HelloWorldFunction --debug
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
'build' command is called
No Parameters detected in the template
2 resources found in the template
Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
Building resource 'HelloWorldFunction'
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
calling pip download -r /Users/rick/PycharmProjects/same_hello_world/hello_world/requirements.txt --dest /var/folders/nd/7xg436m51nb5k7zc7pmc1bp80000gn/T/tmpym0ydzw_
PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 39, in execute
    requirements_path=self.manifest_path
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 144, in build_dependencies
    requirements_path, artifacts_dir_path, scratch_dir_path)
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 210, in build_site_packages
    scratch_directory, requirements_filepath)
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 235, in _download_dependencies
    requirements_filename, directory)
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 331, in _download_all_dependencies
    self._pip.download_all_dependencies(requirements_filename, directory)
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 632, in download_all_dependencies
    raise NoSuchPackageError(str(package_name))
aws_lambda_builders.workflows.python_pip.packager.NoSuchPackageError: Could not satisfy the requirement: requests

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 248, in run
    action.execute()
  File "/usr/local/Cellar/aws-sam-cli/0.40.0/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 42, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Could not satisfy the requirement: requests

Build Failed
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 8869, 'exitReason': 'BuildError', 'exitCode': 1, 'requestId': '59b95c5f-41ad-4a49-8a2c-bbe3c8cfff0c', 'installationId': '1b04c3a5-0596-4d35-adf5-3b3eb72e3c41', 'sessionId': '117d5400-f707-425e-ab00-3607943c3672', 'executionEnvironment': 'CLI', 'pyversion': '3.7.6', 'samcliVersion': '0.40.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: requests

Please provide command output with --debug flag set.

Expected result

Successful Build

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: MacOS Catalina 10.15.2
  2. sam --version: SAM CLI, version 0.40.0

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vstathokcommented, Mar 19, 2020

Ok, I figured out the cause of the problem. If you look your error stack, the process fails at the part

calling pip download -r /Users/rick/PycharmProjects/same_hello_world/hello_world/requirements.txt --dest /var/folders/nd/7xg436m51nb5k7zc7pmc1bp80000gn/T/tmpym0ydzw_ PythonPipBuilder:ResolveDependencies failed

I tried to execute that command in the command prompt to see what happens, in my case it was:

pip download -r C:\Users\IdeaProjects\my_projects\requirements.txt --dest C:\Users\USER~1\AppData\Local\Temp\tmp9ya2xf94

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/pandas/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/pandas/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/pandas/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/pandas/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)’: /simple/pandas/ Could not fetch URL https://pypi.org/simple/pandas/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /simple/pandas/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) - skipping ERROR: Could not find a version that satisfies the requirement pandas (from -r C:\Users\IdeaProjects\my_projects\requirements.txt (line 1)) (from versions: none) ERROR: No matching distribution found for pandas (from -r C:\Users\IdeaProjects\my_projects\requirements.txt (line 1))

After some search, I figured out that I had to add to my path environment variable the following paths: D:\Anaconda3; D:\Anaconda3\Scripts; D:\Anaconda3\Library\bin

The credits go to @无名小路 Link: https://stackoverflow.com/questions/45954528/pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl-module-in/54897379#54897379?newreg=3ad8ab28763c435ab709ef73d7f638b3

0reactions
vstathokcommented, Mar 19, 2020

@rickbhardwaj I am getting exactly the same error. What did you do eventually to solve it? My environment details are:

  • Windows 10
  • Intellij 2019.3.3
  • sam version 0.44.0
  • docker version 19.03.8

I had exactly the same code running successfully (build, invoking function, creating stack) on another machine (at my workplace), the only difference is that that docker version there was 19.03.05. Now with covid19 we were given other machines to work from home. I am not working behind any VPN or proxy for the time being therefore I would expect for the code to run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyCharm new AWS Serverless Application not creating any ...
Install AWS Plugin into PyCharm (2020.1 Community - Windows 10 Pro 64 bit); Create a new AWS Serverless Application project; Select the AWS...
Read more >
Requirements file not found while deploying SAM tutorial app
If you are using docker, copy the requirements.txt to the root of your project. That should fix it.
Read more >
sam build - AWS Serverless Application Model
Build an AWS SAM application using the sam build command from the AWS SAM CLI. ... to the AWS Cloud, see Tutorial: Deploying...
Read more >
AWS Lambda Testing and Debugging using IntelliJ, AWS ...
To solve this error, just go to File -> Settings -> Tools -> AWS and check if the path for SAM CLI executables...
Read more >
Building Serverless Applications with the AWS Toolkit for ...
Learn more about the AWS Serverless Application Model at - https://amzn.to/2TBM00i. ... Your browser can't play this video.
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