【问题标题】:How to solve this error while installing python packages in RStudio?在 RStudio 中安装 python 包时如何解决这个错误?
【发布时间】:2019-02-06 16:34:50
【问题描述】:

我给出了以下命令

图书馆(网状)

py_install("熊猫")

在 RStudio 中安装 python 包时出现错误:

Solving environment: ...working... failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/noarch/repodata.json.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/noarch/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
Error: Error 1 occurred creating conda environment r-reticulate

请帮助解决此错误。

【问题讨论】:

  • 你到底在运行什么命令?
  • 看起来像是某些 SSL 库的问题。什么是操作系统?
  • @heisenbug47,我怀疑重点是在 RStudio 中安装 python 包(使用 R 的 reticulate 包),而不是 R 包 .
  • @r2evans, reticulate 包用于在 R Studio 或 R 代码中执行 python 代码,据我所知,它不用于安装任何包。它在 R.Refer this 中提供了 python 环境以获取更多详细信息。如果使用 anconda,则需要像往常一样通过 pip 或 conda 安装 Python 包。要在 R 中使用它,请使用 reticulate 并提及安装 python 包的正确路径。
  • 嗯?我是在回复你之前的评论。既然您似乎知道需要通过pipconda 安装python 包,那您为什么建议install.packages()

标签: r


【解决方案1】:

解决了由 install_tensorflow() 引起的类似错误:

SSLError("Can't connect to HTTPS URL because the SSL module is not available."))'))

通过将 openssl.exe 的路径添加到 Windows 的 %PATH% 环境变量中。在我的电脑中,路径是这样的(用你的替换“[用户名]”):

C:\Users\[username]\Anaconda3\pkgs\openssl-1.1.1b-he774522_1\Library\bin

如果您的 openssl 是旧版本(如此处所述:https://github.com/conda/conda/issues/8046),您可以按照以下指南安装最新版本:

https://jchornsey.wordpress.com/2015/03/17/installing-openssl-in-windows-8-1/ https://www.cloudinsidr.com/content/how-to-install-the-most-recent-version-of-openssl-on-windows-10-in-64-bit/

正如这些指南所解释的,“OpenSSL 官方网站仅提供 Linux 源。”对于 Windows 二进制文件,您可以从 Shining Light Productions 提供的https://slproweb.com/products/Win32OpenSSL.html 获取。 github 问题讨论提到此链接列在 OpenSSL wiki 上(https://wiki.openssl.org/index.php/Binaries - 我两天前去那里确认但今天该页面未加载,可能是由于复活节假期)。

指南还解释说,“如果您不开发软件,则不需要完整版本;“Light”版本是为最终用户设计的。

【讨论】:

  • 虽然这回答了这个问题,但您应该 edit 您的回答将底部链接中更重要的部分包含在答案本身中。如果链接因任何原因停止工作,这有助于防止这部分答案变得无效。
【解决方案2】:

从 RStudio 安装 Python 似乎很有趣。一种方法是在 R 中使用 reticulatepackage,它为 Python 提供 R 接口并在 R 中使用 Python。

Python 软件包通常使用pip 或“conda”(如果使用 anaconda)安装。

然后要在 R 中使用它,请提及系统中安装 python 的正确路径。

library(reticulate)
use_python("/usr/local/bin/python")

Reticulate 还提供了一种使用py_install() 函数安装包的方法。

library(reticulate)
py_install("pandas")

请查看有关reticulatepackage here 和安装包here 的更多详细信息。

【讨论】:

  • 这看起来更像是 SSL/HTTP 错误。 anaconda 在系统中是否正常工作?
猜你喜欢
  • 2021-03-20
  • 1970-01-01
  • 1970-01-01
  • 2021-11-02
  • 2017-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-11
相关资源
最近更新 更多