Error when installing rpy2 module in Python with easy_install
There's a much easier way to go about this - install rpy2
from Christoph Gohlke's Python Extension Packages for Windows repository here. Download the rpy2‑2.5.5‑cp34‑none‑win_amd64.whl
file (the current version at the time of this writing), change to the download folder on the command line, and run
pip install rpy2‑2.5.5‑cp34‑none‑win_amd64.whl
pip
is already included in Python 3.4, and should be used instead of easy_install
when installing new modules, as easy_install
is deprecated.
How can I install gekko package using R reticulate?
A more general answer for help in similar cases:
- Install gekko and other packages in a new environment in R.
reticulate::py_install(
packages = c(
"gekko",
"other_package==x.x.x", # It's possible to specify the package version
...
),
envname = "new_env",
method = "conda", # For Windows
python_version = "3.x.x",
pip = TRUE
)
- Call reticulate package using the new environment.
Sys.setenv(RETICULATE_PYTHON = "/Users/user_name/anaconda#/envs/new_env/python.exe")
library(reticulate)
- Run your Python script with gekko in R.
source_python("path/script.py")
Using rpy2: cannot find R package that is installed
Okay, it was a pretty stupid thing:
R installs my packages at two locations on my computer: in an R folder in the Documents and in the actual program folder in Program Files. You can check your locations like this:
> .libPaths()
[1] "C:/Users/XYZ/Documents/R/win-library/3.6"
[2] "C:/Program Files/R/R-3.6.3/library"
rpy2 was only able to use the packages that were installed in location [2].
I simply moved everything from [1] to [2]. Now it works!
Installing rpy2
If you're desperate, you could install WinPython (for windows users) which has a lot of Packages already installed and ready to use, including rpy2, sometimes installing packages on windows can be stressful.
Or if you really want to make it work that way, maybe you could check if that package was installed in the Downloads folder and move it to the folder corresponding to python libraries
Related Topics
Building Python with Ssl Support in Non-Standard Location
Flask Application Traceback Doesn't Show Up in Server Log
Converting Yes and No to 0 and 1 in R
Create Static Graphics Files (Png, Gif, Jpg) Using Ruby or Python
What Programming Language Features Are Well Suited for Developing a Live Coding Framework
How to Convert a File into a Dictionary
Python Popen Command. Wait Until the Command Is Finished
Proper Indentation for Multiline Strings
What Makes Sets Faster Than Lists
How to Specify Working Directory for Popen
Permanent Fix for Opencv Videocapture
Matplotlib Analog of R's 'Pairs'
Efficient Ways to Duplicate Array/List in Python
Ruby Equivalent to Python's Help()
How to Redirect Stdout to Both File and Console with Scripting
Python Mocking Raw Input in Unittests
How to Implement Custom Indentation When Pretty-Printing with the JSON Module