微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 `reticulate` 中使用 `pandas` 模块

如何解决无法在 `reticulate` 中使用 `pandas` 模块

我试图在 R 中使用 keras,当我试图调用 flow_images_from_dataframe() 时发生错误

Error in flow_images_from_dataframe() : 
  Pandas (python module) must be installed in the same environment as Keras.Install it using reticulate::virtualenv_install("pandas",envname = "r-tensorflow") or reticulate::conda_install("pandas",envname = "r-tensorflow") depending on the kind of environment you are using.

我尝试了以下方法

reticulate::py_module_available("pandas")
# FALSE.

# checking that environment is there:
reticulate::virtualenv_list()
# "r-reticulate" "r-tensorflow"

# activate the environment:
use_virtualenv('r-tensorflow')

reticulate::virtualenv_install("pandas",envname = "r-tensorflow")
# ...
# ...
# Installing collected packages: pandas
# Successfully installed pandas-1.1.5

# Trying again:
py_module_available("pandas")
# FALSE

# The issue is specific to pandas,other modules are fine:
reticulate::py_module_available('scipy')
# TRUE

解决方法

我仍然不明白那里的问题是什么以及为什么 virtualenv_install() 没有完成这项工作,但帮助我的解决方案就像

py_install("pandas")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。