Tuesday 31 May 2022

Django - Grabbing a JSON object from QueryDict

 
What I'm doing here is passing some JSON through the 'rest.framework' .  The problem is that when using 'request.json'  I'm seeing the following being returned. 

<QueryDict: {'': ['{"time":{"0":"06:00","1":"07:00","2":"08:00","3":"09:00","4":"10...


What I need to do is extract the JSON out .  To do this , the following works. 

list(data.values())[0]




Wednesday 25 May 2022

M1 Chip issue with AWS Lambda SAM Layers

 

Just a quick note , if you've searched and found this blog then I expect you already know deep down that the M1 chip is your issue.  There is a solution though.  Let me explain. 


So, what we've been doing is using Lambda Layers to install Python packages on our Lambda installation.  However, when putting the same code on my Mac ( M1 Chip ) it doesn't work ! 

https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

It does work if we take the zip file from the AMD64 chipped Mac , and put that on my Mac and proceed. 

That is the solution we're having to use at the moment , the zip needs to be compiled on the AMD64 chip , doing it on the M1 chip won't work. 


Tuesday 17 May 2022

Could not 'pipenv install email' - 'python setup.py egg_info did not run successfully.' error.

Here's the error code I was getting. 

Installing email... Error: An error occurred while installing email! Error text: Collecting email Using cached email-4.0.2.tar.gz (1.2 MB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'error' error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [1 lines of output] ERROR: Can not execute `setup.py` since setuptools is not available in the build environment. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. This is likely caused by a bug in email. Report this to its maintainers. ✘ Installation Failed



The recommended solution across the web seemed to be to run the following. 

pipenv install --upgrade setuptools


However, this didn't work for me.  I needed to use the '--pre' tag. 

pipenv install --pre email


This now works, the version I had the issue with was 'email-4.0.2'


So, if you have a 'email-4.0.2 won't pipenv install' issue then I hope this post helps.