TL;DR :-) 获取 https url 在 python 和 R 中都有效,但在从 R 中运行 python 代码时无效。
在 RKeras 包的文档中运行一些代码时,我反复遇到致命错误:"unknown url type: https"
问题源于用 Python 实现的 Keras。
我深入研究了这个问题,发现这是在 Keras 调用urlretrieve
模块six
中的函数以从 https url 检索数据时发生的。
然后我在 iPython 中测试了代码,发现它运行良好。
<!-- language: lang-python -->
from six.moves.urllib.request import urlretrieve
urlretrieve(url="https://www.google.com")
然后我尝试在 R 中做同样的事情,但它失败了
<!-- language: lang-r -->
library(reticulate)
py_run_string('from six.moves.urllib.request import urlretrieve')
py_run_string("urlretrieve(url='https://www.google.com')")
但是,同样的事情在 R 中也适用于普通的 http
<!-- language:lang-r -->
py_run_string("urlretrieve(url='http://www.google.com')")
作为记录,https 在我的 R 中使用 httr 之类的包可以正常工作。
我在这里完全超出了我的深度。会发生什么?
这是关于我的环境的一些输出
回复:
sessionInfo()
# R version 3.4.4 (2018-03-15)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Ubuntu 16.04.4 LTS
# other attached packages:
# [1] reticulate_1.6 kerasR_0.8.0
和 Python(从 R 看)
py_config()
version: 3.5.2 |Anaconda custom (64-bit)|
(default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
将非常感谢您的时间和精力。
编辑:R中的更多调试信息:
py_run_string("from OpenSSL import SSL")
# ImportError: /xxx/python3.5/lib-dynload/_ssl.so: undefined symbol: SSLv2_method