Hello.
I'm using Tensorflow on R for my research, and I often use "gym" module to check the validity of my reinforcement learning model. There was no problem before installing the Keras interface.
However, I found an error to import Keras and gym modules at the same time, after installing the Keras API.
(When I import just one of these two modules, there was not a problem.)
The following is the detail of the error.
case 1) Import Keras first & import gym after
library(keras)
gym <- import("gym")
(result) Error in import("gym") : could not find function "import"
Error: package or namespace load failed for ‘keras’: ... ImportError: Could not find 'cudart64_80.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 8.0 from this URL: https://developer.nvidia.com/cuda-toolkit
I'm now using gpu version of Tensorflow, but I found the same error on my Laptop using cpu version of Tensorflow.
I don't know why you're seeing an error in the second case (however keras is not your typical R package, and I am not an expert in its internal workings), but the first case is straightforward:
import() is a function in the reticulate package, but here you try to use it before you've loaded reticulate. What happens when you try it this way?
(result) ModuleNotFoundError: No module named 'gym'
In addition, before I installed the Keras API, I used tensorflow module only, and the first case
library(tensorflow)
gym <- import("gym")
works well, with no problem.
These kinds of error come up after I installed Keras API.
This happens because keras is installed on the r-tensorflow virtualenv and gym is probably installed in r-reticulate env. You can install gym on the r-tensorflow env by running:
Thank you so much.
I thought this problem is probably happended because of the path of virtualenv, but I did not know what to do.
Your second advice works well and I checked the following message.