ModuleNotFoundError:没有名为“psycopg2”的模块;当 redshift 连接添加到 Gluejob 时
我正在使用glue 从 redshift 加载数据,glubjob 因 psycopg2 导入错误而失败。 1)我尝试过 --additional-python-modules 导入 psycopg2-binary 的方法,glue 是这样导入模块的,收集 psycopg2-binary 下载 psycopg2_binary-2.9.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)安装收集的软件包: psycopg2-binary已成功安装psycopg2-binary-2.9.3。 但作业失败并出现以下错误, redshift.amazonaws.com”,端口 5439 失败:连接超时 服务器是否在该主机上运行并接受 TCP/IP 连接?
- 我尝试将 redshift 连接附加到粘合作业,这次失败,出现 ModuleNotFoundError: No module named 'psycopg2' 错误,原因如下,无法获取 URL https://pypi.org/simple/psycopg2-binary/:确认 ssl 时出现问题证书:HTTPSConnectionPool(主机='pypi.org',端口=443):超过最大重试次数,网址:/simple/psycopg2-binary/(由SSLError(SSLError(1,'[SSL:UNKNOWN_PROTOCOL]未知协议(_ssl. c:1091)'))) - 跳过无法获取 URL https://pypi.org/simple/pip/:确认 ssl 证书时出现问题:HTTPSConnectionPool (host='pypi.org', port=443): url 超出最大重试次数:/simple/pip/ (由 SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] 未知协议 (_ssl.c:1091)'))) - 跳过
我尝试了其他选项,例如压缩 psycopg2-二进制模块,将其上传到 s3 并在glue中使用 python 库路径中的路径,但仍然找不到模块错误。 任何帮助将不胜感激。 提前致谢。
I'm using glue to load data from redshift, glubjob is failing with psycopg2 import error. 1) I tried
--additional-python-modules method to import psycopg2-binary, glue is importing the module like this, Collecting psycopg2-binary Downloading psycopg2_binary-2.9.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)Installing collected packages: psycopg2-binarySuccessfully installed psycopg2-binary-2.9.3.
But the job is failed with below error,
redshift.amazonaws.com", port 5439 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
- I tried by attaching redshift connection to the glue job, this time it is failed with ModuleNotFoundError: No module named 'psycopg2' error and below is the reason for that,Could not fetch URL https://pypi.org/simple/psycopg2-binary/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/psycopg2-binary/ (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:1091)'))) - skippingCould not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:1091)'))) - skipping
I have tried other options like zipping the psycopg2-binary module, uploading it to s3 and used the path in python library path in glue but still getting module not found error.
Any help would be appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于一组不同的库,我面临着同样的问题。即使我安装了库,它也会抛出错误。所以我发现了这个代码片段并添加到我的代码中,它对我有用。
您可以在脚本的开头添加,看看这是否适合您。
以下是在glue中安装附加Python模块指南的链接 -
https://docs.aws。 amazon.com/glue/latest/dg/aws-glue-programming-python-libraries.html
I was facing the same issue for a different set of libraries. Even i installed the libraries it was throwing the error. so I found out about this code snip and added in my code and it worked for me.
You can add at the start of your script and see if this works for you.
Here is the link to the guide for Installing Additional Python Modules in glue -
https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-libraries.html