lambda-proxy icon indicating copy to clipboard operation
lambda-proxy copied to clipboard

Unable to use Pycharm debug mode because of DistributionNotFound Error

Open emiliajin opened this issue 5 years ago • 0 comments

Environment details:

  • OS: macOS
  • Python version: python3.7/3.8
  • lambda-proxy version: 5.2.1

Issue:

We are trying to apply lambda-proxy for our AWS Lambda Development. However there is some problem when we trying to use Pycharm/IntelliJ to local debug our Lambda function. In Running mode is everything fine. But in Debug mode we meet the strange DistributionNotFound Error. Since our Lambda Function involve some Crypto package, we have to build our function inside a container. Here is the error we meet in Debug mode:

/usr/local/bin/sam local invoke Function --template xxxxx/lambda/.aws-sam/build/template.yaml --event "/private/var/folders/wf/xxxxxxx/T/[Local] Function-event7.json" --debug-port 64332 --debugger-path "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev" --debug-args "-u /tmp/lambci_debug_files/pydevd.py --multiprocess --port 64332 --file" Invoking entry_point.lambda_handler (python3.7) Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-python3.7:rapid-1.6.2.

Mounting xxxx/lambda/.aws-sam/build/Function as /var/task:ro,delegated inside runtime container Connected to pydev debugger (build 193.5662.61) [ERROR] DistributionNotFound: The 'lambda_proxy' distribution was not found and is required by the application Traceback (most recent call last):   File "/var/lang/lib/python3.7/imp.py", line 234, in load_module     return load_source(name, filename, file)   File "/var/lang/lib/python3.7/imp.py", line 171, in load_source     module = _load(spec)   File "", line 696, in _load   File "", line 677, in _load_unlocked   File "", line 728, in exec_module   File "", line 219, in _call_with_frames_removed   File "/var/task/entry_point.py", line 2, in     import api_instance as api_instance   File "/var/task/api_instance.py", line 1, in     from lambda_proxy.proxy import API   File "/var/task/lambda_proxy/init.py", line 5, in     version = pkg_resources.get_distribution(package).version   File "/var/lang/lib/python3.7/site-packages/pkg_resources/init.py", line 482, in get_distribution     dist = get_provider(dist)   File "/var/lang/lib/python3.7/site-packages/pkg_resources/init.py", line 358, in get_provider     return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]   File "/var/lang/lib/python3.7/site-packages/pkg_resources/init.py", line 901, in require     needed = self.resolve(parse_requirements(requirements))   File "/var/lang/lib/python3.7/site-packages/pkg_resources/init.py", line 787, in resolve     raise DistributionNotFound(req, requirers)

We have search that there is some issue regarding pkg_resources.get_distribution(..).version https://github.com/googleapis/python-api-core/issues/27

emiliajin avatar Oct 27 '20 09:10 emiliajin