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.

"'NoneType' object is not callable" when running on Lambda

See original GitHub issue

I’m trying to get this to successfully run in an AWS Lambda function and keep getting the error:

Traceback (most recent call last):
  File "handler.py", line 27, in <module>
    rsa_private_key_passphrase = boxPrivateKeyPassphrase
TypeError: 'NoneType' object is not callable

The area where it’s failing is:

    enterpriseAuth = JWTAuth(
        client_id=boxClientId,
        client_secret=boxClientSecret,
        enterprise_id=boxEnterpriseId,
        jwt_key_id=boxJwtKeyId,
        rsa_private_key_file_sys_path=boxPrivateKeyPath,
        rsa_private_key_passphrase=boxPrivateKeyPassphrase
    )

I could duplicate it on an EC2 instance with modules packaged with the script in a vendored directory.

.
β”œβ”€β”€ boxsdk
β”‚Β Β  β”œβ”€β”€ auth
β”‚Β Β  β”œβ”€β”€ client
β”‚Β Β  β”œβ”€β”€ network
β”‚Β Β  β”œβ”€β”€ object
β”‚Β Β  β”œβ”€β”€ session
β”‚Β Β  └── util
β”œβ”€β”€ boxsdk-1.5.3.dist-info
β”œβ”€β”€ enum
β”œβ”€β”€ enum34-1.1.6.dist-info
β”œβ”€β”€ idna
β”œβ”€β”€ idna-2.1.dist-info
β”œβ”€β”€ ipaddress-1.0.16.dist-info
β”œβ”€β”€ jwt
β”‚Β Β  └── contrib
β”œβ”€β”€ pkg_resources
β”‚Β Β  β”œβ”€β”€ extern
β”‚Β Β  └── _vendor
β”œβ”€β”€ pyasn1
β”‚Β Β  β”œβ”€β”€ codec
β”‚Β Β  β”œβ”€β”€ compat
β”‚Β Β  └── type
β”œβ”€β”€ pyasn1-0.1.9.dist-info
β”œβ”€β”€ pycparser
β”‚Β Β  └── ply
β”œβ”€β”€ pycparser-2.14.egg-info
β”œβ”€β”€ PyJWT-1.4.0.dist-info
β”œβ”€β”€ requests
β”‚Β Β  └── packages
β”œβ”€β”€ requests-2.10.0.dist-info
β”œβ”€β”€ requests_toolbelt
β”‚Β Β  β”œβ”€β”€ adapters
β”‚Β Β  β”œβ”€β”€ auth
β”‚Β Β  β”œβ”€β”€ cookies
β”‚Β Β  β”œβ”€β”€ downloadutils
β”‚Β Β  β”œβ”€β”€ multipart
β”‚Β Β  β”œβ”€β”€ threaded
β”‚Β Β  └── utils
β”œβ”€β”€ requests_toolbelt-0.6.2.dist-info
β”œβ”€β”€ setuptools
β”‚Β Β  β”œβ”€β”€ command
β”‚Β Β  └── extern
β”œβ”€β”€ setuptools-24.0.2.dist-info
└── six-1.10.0.dist-info

The only way to get it to work on EC2 is by sudo pip install boxsdk[jwt] on the system packages after installing a number of dependencies like libffi-devel, gcc and openssl-devel.

So does anyone know what’s missing that I could bundle with the function into Lambda in order to get this working?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jmoldowcommented, Jul 7, 2016

See https://github.com/box/box-python-sdk/blob/master/boxsdk/auth/__init__.py#L10 .

JWTAuth is only defined if its dependencies are available (which you get with pip install boxsdk[jwt]). If you’re using a Python virtualenv, you should make sure these dependencies are installed into your virtualenv with pip. If you’re running directly with the system’s python, you’ll need sudo pip.

Compiling the cryptography dependency on Linux does require libffi-devel, gcc and openssl-devel: https://github.com/pyca/cryptography/blob/master/docs/installation.rst#building-cryptography-on-linux

I don’t know anything about Lambda, so I don’t know what would be different about getting it to work on Lambda, as opposed to EC2. In the directory tree you posted, I don’t see cryptography, which is probably why JWTAuth isn’t able to be imported and defined.

0reactions
GelosSnakecommented, Jun 12, 2018

was the issue solved? I’m getting this error as well. Here is my tree, did both boxsdk[jwt] and cryptography. Everything was compiled on AmazonLinux docker.

. β”œβ”€β”€ asn1crypto β”‚Β Β  └── _perf β”œβ”€β”€ asn1crypto-0.24.0.dist-info β”œβ”€β”€ bin β”œβ”€β”€ boxsdk β”‚Β Β  β”œβ”€β”€ auth β”‚Β Β  β”œβ”€β”€ client β”‚Β Β  β”œβ”€β”€ network β”‚Β Β  β”œβ”€β”€ object β”‚Β Β  β”œβ”€β”€ session β”‚Β Β  └── util β”œβ”€β”€ boxsdk-1.5.5.dist-info β”œβ”€β”€ certifi β”œβ”€β”€ certifi-2018.4.16.dist-info β”œβ”€β”€ cffi β”œβ”€β”€ cffi-1.11.5.dist-info β”œβ”€β”€ chardet β”‚Β Β  └── cli β”œβ”€β”€ chardet-3.0.4.dist-info β”œβ”€β”€ cryptography β”‚Β Β  β”œβ”€β”€ hazmat β”‚Β Β  β”‚Β Β  β”œβ”€β”€ backends β”‚Β Β  β”‚Β Β  β”‚Β Β  └── openssl β”‚Β Β  β”‚Β Β  β”œβ”€β”€ bindings β”‚Β Β  β”‚Β Β  β”‚Β Β  └── openssl β”‚Β Β  β”‚Β Β  └── primitives β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asymmetric β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ciphers β”‚Β Β  β”‚Β Β  β”œβ”€β”€ kdf β”‚Β Β  β”‚Β Β  └── twofactor β”‚Β Β  └── x509 β”œβ”€β”€ cryptography-2.2.2.dist-info β”œβ”€β”€ enum β”œβ”€β”€ enum34-1.1.6.dist-info β”œβ”€β”€ idna β”œβ”€β”€ idna-2.6.dist-info β”œβ”€β”€ ikpdb-1.2.3.dist-info β”œβ”€β”€ ipaddress-1.0.22.dist-info β”œβ”€β”€ pycparser β”‚Β Β  └── ply β”œβ”€β”€ pycparser-2.18.dist-info β”œβ”€β”€ requests β”œβ”€β”€ requests-2.18.4.dist-info β”œβ”€β”€ requests_toolbelt β”‚Β Β  β”œβ”€β”€ adapters β”‚Β Β  β”œβ”€β”€ auth β”‚Β Β  β”œβ”€β”€ cookies β”‚Β Β  β”œβ”€β”€ downloadutils β”‚Β Β  β”œβ”€β”€ multipart β”‚Β Β  β”œβ”€β”€ threaded β”‚Β Β  └── utils β”œβ”€β”€ requests_toolbelt-0.8.0.dist-info β”œβ”€β”€ six-1.11.0.dist-info β”œβ”€β”€ urllib3 β”‚Β Β  β”œβ”€β”€ contrib β”‚Β Β  β”‚Β Β  └── _securetransport β”‚Β Β  β”œβ”€β”€ packages β”‚Β Β  β”‚Β Β  β”œβ”€β”€ backports β”‚Β Β  β”‚Β Β  └── ssl_match_hostname β”‚Β Β  └── util └── urllib3-1.22.dist-info

Any idea?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: <lambda> TypeError: 'NoneType' object is not ...
I am trying to call a function called Add_user from another function called Edit_user_admin , I'm pretty sure I have written everythingΒ ...
Read more >
Python TypeError: 'nonetype' object is not callable Solution
β€œTypeError : 'nonetype' object is not callable” occurs when you try to call a None value as if it were a function. ......
Read more >
TypeError: 'NoneType' object is not callable in Python
The Python "TypeError: 'NoneType' object is not callable" occurs when we try to call a None value as if it were a function....
Read more >
TypeError: 'NoneType' object is not callable : r/aws
I'm running into an error after deploying my django app to lambda ... to lambda using zappa - TypeError: 'NoneType' object is not...
Read more >
"TypeError: 'NoneType' object is not callable" raised when ...
Just run Debug and check console over and over again. ... Found in pycharmPY-142.4957 build. ... I've had the same crash on 2019.2...
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