[PYTHON] Problems that occurred when introducing rpy2

Introduction

This article is a migration of an article that was previously created and published on another site.

This article assumes the following:

--R for Windows must be installed

The operation check environment is as follows.

Problems and solutions that occur

I can't install rpy2 with pip

Solution

Install using the Wheel package

procedure

  1. Download the rpy2 whl file that suits your environment from here
  2. At the command prompt, move to the location where you stored the whl file.
  3. Install with pip
pip install (whl file name)

If the following message is output, the whl file is incorrect. Does the file name match? Are you using a whl file other than the environment in which it is installed? Check etc. rpy2XXX.whl is not a supported wheel on this platform.

"Runtime Error: R_HOME not defined." Was output when importing with Python

Cause

Environment variables are not set

Solution

Set the R installation folder in the Windows system environment variable

Variable name Variable value
R_HOME C:\Program Files\R\R-3.5.2

important point

--Please change appropriately according to the location where R is installed and the version of R installed. --If you started the command prompt when you changed the environment variable, you need to restart the command prompt.

"Runtime Error: R_USER not defined." Was output when importing with Python

Cause

Environment variables are not set

Solution

Set the R execution user in the Windows system environment variable

Variable name Variable value
R_USER (R execution user name)

important point

--If you started the command prompt when you changed the environment variable, you need to restart the command prompt.

"ModuleNotFoundError: No module named'tzlocal'" was output when importing with Python

Cause

Missing python module tzlocal

Solution

Install tzlocal with pip

procedure

  1. Install tzlocal with pip
pip install tzlocal

that's all

Recommended Posts

Problems that occurred when introducing rpy2
MalformedPolicyDocumentException occurred when put_role_policy
Work memo when introducing mitmproxy
[Linux / GCP] Corrected the error that occurred when using the Git command.