I am trying to use the library psycopg2
in AWS Glue.
I followed this question:
"What I did was install psycopg2-binary into a directory and zip up the contents of that directory:
mkdir psycopg2-binarycd psycopg2-binarypip install psycopg2-binary -t .zip -r9 psycopg2.zip *
I then copied psycopg2.zip to an S3 bucket and added it as an extra Python library under "Python library path" in the Glue Spark job.
But I got this error when I tried to import the library import psycopg2
:
import psycopg2 File "/tmp/psycopg2.zip/psycopg2/__init__.py", line 51, in <module> from psycopg2._psycopg import ( # noqaModuleNotFoundError: No module named 'psycopg2._psycopg'
- I am using
Python 3.9
- I uploaded the zip in the
Python library path
.
I also tried to zip only the psycopg2 folder (not the entire project) and obtained the same error.
I also tried to pass the Job parameters
as --additional-python-modules
:psycopg2
without the zip file, this way Glue would try to install it. But I got the following error:
Error Category: IMPORT_ERROR; ModuleNotFoundError: No module named 'psycopg2'
Also tried --additional-python-modules
:psycopg2-binary==2.9.9
with the same error.
The package is being installed, but the import is not working.