Skip to content

Commit de1fdbf

Browse files
committed
improved Windows installation guide.
1 parent 40fed92 commit de1fdbf

File tree

5 files changed

+347
-190
lines changed

5 files changed

+347
-190
lines changed

README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@ To cite the Python module ‘arulespy’ in publications use:
5050

5151
## Installation
5252

53-
**Note:** `rpy2` currently does not support Windows and the installation is tricky (see [here](https://rpy2.github.io/doc/v3.5.x/html/overview.html#installation)).
54-
5553
`arulespy` is based on the python package `rpy2` which requires an R installation. Here are the installation steps:
5654

5755
1. Install the latest version of R (>4.0) from https://www.r-project.org/
5856

59-
2. Install required libraries/set path depending on your OS:
57+
2. Install required libraries on your OS:
6058
- libcurl is needed by R package [curl](https://cran.r-project.org/web/packages/curl/index.html).
6159
- Ubuntu: `sudo apt-get install libcurl4-openssl-dev`
6260
- MacOS: `brew install curl`
63-
- Windows: no installation necessary
64-
- Environment variable `R_HOME` may need to be set for Windows
61+
- Windows: no installation necessary, but read the Windows section below.
6562

6663
3. Install `arulespy` which will automatically install `rpy2` and `pandas`.
6764
``` sh
@@ -76,10 +73,46 @@ To cite the Python module ‘arulespy’ in publications use:
7673
`install.packages(c("arules", "arulesViz"))`
7774

7875

79-
The most likely issue is that `rpy2` does not find R.
76+
The most likely issue is that `rpy2` does not find R or R's shared library.
8077
This will lead the python kernel to die or exit without explanation when the package `arulespy` is imported.
8178
Check `python -m rpy2.situation` to see if R and R's libraries are found.
82-
Details can be found [here](https://pypi.org/project/rpy2/).
79+
If you use iPython notebooks then you can include the following code block in your notebook to check:
80+
```python
81+
from rpy2 import situation
82+
83+
for row in situation.iter_info():
84+
print(row)
85+
```
86+
87+
The output should include a line saying `Loading R library from rpy2: OK`.
88+
89+
### Note for Windows users
90+
`rpy2` currently does not fully support Windows and the installation is somewhat tricky. I was able to use it with the following setup:
91+
92+
* Windows 10
93+
* rpy2 version 3.5.14
94+
* Python version 3.10.12
95+
* R version 4.3.1
96+
97+
I use the following code to set the needed environment variables needed by Windows
98+
before I import from `arulespy`
99+
```python
100+
from rpy2 import situation
101+
import os
102+
103+
r_home = situation.r_home_from_registry()
104+
r_bin = r_home + '\\bin\\x64\\'
105+
os.environ['R_HOME'] = r_home
106+
os.environ['PATH'] = r_bin + ";" + os.environ['PATH']
107+
os.add_dll_directory(r_bin)
108+
109+
for row in situation.iter_info():
110+
print(row)
111+
```
112+
113+
The output should include a line saying `Loading R library from rpy2: OK`
114+
115+
More information on installing `rpy2` can be found [here](https://pypi.org/project/rpy2/).
83116
84117
85118
## Example

0 commit comments

Comments
 (0)