如何在 Windows 7 上使用 Python 3 和 httplib2 调用 AWS?

发布于 2024-11-29 02:26:13 字数 660 浏览 2 评论 0原文

我正在使用 httplib2 来调用 Amazon Web Services (AWS):

http = httplib2.Http(cache='.cache')
response, content = http.request('https://sdb.amazonaws.com/...')

但是它无法寻找 CA(我认为):

File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 1059, in request self.disable_ssl_certificate_validation)
File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 772, in __init__ context.load_verify_locations(ca_certs)
IOError: [Errno 2] No such file or directory

我的问题:

  1. 我需要做些什么来配置我的操作系统和环境才能使其正常工作吗?
  2. 我看过很多关于确保在 Python 2 中为 SSL 构建套接字库的文章;这适用于 Python 3 吗?

谢谢!

I am using httplib2 to make calls to Amazon Web Services (AWS):

http = httplib2.Http(cache='.cache')
response, content = http.request('https://sdb.amazonaws.com/...')

However it fails looking for CAs (I think):

File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 1059, in request self.disable_ssl_certificate_validation)
File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 772, in __init__ context.load_verify_locations(ca_certs)
IOError: [Errno 2] No such file or directory

My questions:

  1. Is there something I need to do to configure my OS and environment for this to work?
  2. I've seen a lot of posts about making sure the sockets library is built for SSL in Python 2; does that apply to Python 3?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你穿错了嫁妆 2024-12-06 02:26:13

httplib2 /Python3 文件夹缺少 cacerts.txt,因此不会将其复制到 Python /lib 文件夹。我手动将文件复制到那里,一切正常。这是 httplib2 的一个已知问题。

The httplib2 /Python3 folder is missing cacerts.txt, so it doesn't get copied to the Python /lib folder. I copied the file there manually and everything worked. This is a known issue with httplib2.

我只土不豪 2024-12-06 02:26:13

我知道游戏已经很晚了,但我的问题与 bash 配置文件中的错误 PYTHONPATH 命令有关,因此该目录被放置在错误的位置。

解决方案是删除我的 bash 配置文件中的 PYTHONPATH 命令,瞧。

I know late to the game but my issue was related to a bad PYTHONPATH command in my bash profile and thus the directory was being put in the incorrect location.

Solution was to remove the PYTHONPATH command in my bash profile and voila.

初熏 2024-12-06 02:26:13

我花了几个小时试图弄清楚这个问题,最后我得到了答案。如果您从其他来源或计算机下载证书 (CA) 文件而被阻止,则在 Windows 上可能会发生这种情况。右键单击证书文件并选中“取消阻止”框。

I spent hours trying to figure this out and finally I have an answer. This can happen on Windows if the certificate (CA) file is blocked if you downloaded it from another source or computer. Right click on the cert file and check the "unblock" box.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文