最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Unable to install and use Keras in R - Stack Overflow

programmeradmin2浏览0评论

I am working in the following environment: Windows 11, R 4.4.3 and RStudio, Python 3.13.2, and Anaconda 25.1.1. Keras 3 is installed along with Tensorflow and reticulate

I am trying to install and run Keras on R for the past month. After facing numerous errors along the way, I seem to be stuck at the following error:

Error in stop_no_virtualenv_starter(version = version, python = python) : 
  Suitable Python installation for creating a venv not found.
  Requested version constraint: >=3.9,<=3.11

I have a hard time believing that I need to downgrade python

I am using the following simple code:

library(keras3)
library(tensorflow)
library(reticulate)
keras3::install_keras(backend = "tensorflow")

this triggers the aforementioned error.

I am working in the following environment: Windows 11, R 4.4.3 and RStudio, Python 3.13.2, and Anaconda 25.1.1. Keras 3 is installed along with Tensorflow and reticulate

I am trying to install and run Keras on R for the past month. After facing numerous errors along the way, I seem to be stuck at the following error:

Error in stop_no_virtualenv_starter(version = version, python = python) : 
  Suitable Python installation for creating a venv not found.
  Requested version constraint: >=3.9,<=3.11

I have a hard time believing that I need to downgrade python

I am using the following simple code:

library(keras3)
library(tensorflow)
library(reticulate)
keras3::install_keras(backend = "tensorflow")

this triggers the aforementioned error.

Share Improve this question edited 21 hours ago desertnaut 60.5k32 gold badges155 silver badges181 bronze badges asked Mar 31 at 16:33 OSH.DC51OSH.DC51 234 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

First of all, you should update your Reticulate package to the latest version, which is 1.41 because a new function for handling Python dependencies has been included, py_require(). You can read more about it here

After updating the package, in your R console run:

py_require("keras")

When you do this, Reticulate will automatically handle the installation and loading of the specified Python package when the Python session is initialized.

It will create an ephemeral virtual environment that will be used to manage the Python dependencies declared via py_require() and resolve any conflicts behind the scenes.

If you then want to import the installed package, run:

kr <- import("keras")
发布评论

评论列表(0)

  1. 暂无评论