我有一个奇怪的问题,希望得到帮助。我的 Python 代码使用请求模块通过 HTTPS 通过 Internet 获取 JSON 信息。尽管我必须按照 this link 中的讨论安装 OpenSSL/PyOpenSSL,但在非 virtenv Python 实例中一切正常。删除不安全的平台通知。
现在,作为使用 Flask 的一部分,我创建了一个虚拟环境。不幸的是,SSL 错误又回来了,上面链接中列出的每个方法都不起作用。这是错误消息:
/home/pi/.virtualenvs/flasktest1/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning
最明显的解决方案是在 virtenv 中安装 OpenSSL/PyOpenSSL,但不幸的是安装失败并出现以下错误。
Command "/home/pi/.virtualenvs/flasktest1/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-6D2PfU/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-o43kpB-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pi/.virtualenvs/flasktest1/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-6D2PfU/cffi
我现在不知道如何解决这个问题。需要明确的是,此应用程序是在防火墙后开发的,仅用于实验目的,不会公开访问。然而,这个错误造成了困难,我只想让它停止。
提前致谢!
最佳答案
对于我 (OS X 10.10),pip install pyopenssl ndg-httpsclient pyasn1
解决了这个问题。
关于python - 无法使用 Raspberry Pi 删除 Python virtualenv 中的 SSL 安全错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29989632/