"Error: Tried to guess R's HOME but no R command in the PATH" - rpy2

"Error: Tried to guess R's HOME but no R command in the PATH"
after runing [ rpy2-2.5.6]$ python setup.py install commands in my redhat server

Try to install libraries always with pip instead of messing around yourself with setup.py files.
I run into the same error under windows 8, R Version 3.3.1 and Python 2.7, 32bit. The solution is easy but for this case the normal pip install rpy2 does not work.
Instead try to use the Windows-Binaries you find them here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2. Download the suiting whl file for your configuration. Then go to your download folder in cmd and simply use:
pip install rpy2-2.7.8-cp27-none-win32.whl
Note, make sure you adapt this code to your download file.

I found out that this happens to me because I'm trying to install on a python version 2.6.5 and the setup.py script tries to use a method subprocess.check_output that is new on 2.7, hence it raises an exception that leads to the this message. It seems to be wise to use a 2.7 or later version, because the check_output method is used several times in the setup.py script.

This worked for me on my Mac using python 2.7:
In my ~/.profile (or use ~/.bashrc)
I set:
export R_HOME=/Library/Frameworks/R.framework/Versions/Current/Resources/
export PATH=$R_HOME:$PATH
sourced it (source ~/.profile) and then did the standard
pip install rpy2

Related

Spyder, clean Win installation, ver. 4.2.3 - pip gives message "No module named pip"

I have Spyder, clean Win10 installation, ver. 4.2.3.
When I run command pip, it gives message:
Note: you may need to restart the kernel to use updated packages.
C:\Users\UserName\AppData\Local\Programs\Spyder\Python\python.exe: No module named pip
I restarted Spyder, Win10, nothing helps.
How to fix it?
Thanks.
(Spyder maintainer here) We don't provide pip in our Windows app to prevent people breaking Spyder by installing any kind of packages with it.
The best way to use other packages that don't come with our app is to install Miniconda, create a conda environment after that with the packages you want to use and spyder-kernels, and finally connect Spyder to that env.
If you have python 3.4+ then pip should be installed with python.
To check that, you can run
pip help
in your windows command line.
However, if it isn't the case then download the get-pip.py file and run
python get-pip.py
and the pip installation should start. You can use pip help to verify this.
Another source of the problem might be that pip isn't listed in your PATH variables and thus isn't recognized by your command line.

virtualenv couldn't find python interpreter path?

my computer have python3.4, python3.5, python3.6, python3.7, but now i want to use python virtualenv to create a env , but it show path not found?
The image in here:
You need to provide the full path to Python, for example:
virtualenv.exe -p C:\Python37\python.exe
For git-bash the command should be slightly different:
virtualenv.exe -p /c/Python37/python.exe
First of all having multiple versions of Python is not advised especially if you cant manage them. The issue you are getting stems from the installation of the Virtualenv package. You need to use the python version that has Virtualenv in the site-packages. Examine all the site packages for the 3 versions then use the one that has virtualenv alternatively you can uninstall all the 3 versions and reinstall one I'd advise on Python 3.6 then install virtualenv via pip and try again.

import ortools in mac

I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source

Trouble installing using PIP

I'm having trouble importing plotly using pip install. The error I get is as follows:
The following command must be run outside of the IPython shell:
$ pip install plotly
The Python package manager (pip) can only be used from outside of IPython.
Please reissue the `pip` command in a separate terminal or command prompt.
I'm very new to programming, so I simply tried this in the windows command prompt and it said "pip is not recognized as an internal or external command, operable program, or batch file". I'm using Spyder if that helps, but I'm not sure what I'm missing here.
Thanks for your help.
I guess you forgot to put ! before pip.
try:
!pip install plotly
in your notebook, should work.
For windows the cleanest way to install a python package is to:
python -m pip install [packagename]
This removes the ambiguity if pip is added to the path variable or not.
If you are getting below error while installing any python packages in window using command "pip install packageName".
The following command must be run outside of the IPython shell:
$ pip install configobj
The Python package manager (pip) can only be used from outside of IPython.
Please reissue the `pip` command in a separate terminal or command prompt.
See the Python documentation for more information on how to install packages:
https://docs.python.org/3/installing/
solution: add "!" at beginning of pip
!pip install configobj(packageName)
It will work. It worked in my case.
What worked for me was going to the directory in which Spyder is located, which you can do by searching Spyder on your computer and then right clicking → directory, and then in the directory opening the Anaconda Prompt. In this Prompt you can type in:
pip install [packagename]
and it will work.

Installation of tkinter on python3

I'm using Fedora 21. Installed the python3-tkinter package using yum install python3-tkinter. The package gets stored in the /usr/lib64/python3.4 directory. Is there a way to use pip to install tkinter?
Have a virtualenv setup with python3. When I try to run my program within that virtualenv I get:
ImportError: No module named 'tkinter'.
Does it make sense to copy the package directories from /usr/lib64/python3.4 to the site_packages folder associated with the virtualenv?
I was using python 3.3.2 interpreter. Turns out the default packages installed when running the command yum install python3-tkinter are set to work with python 3.4.1 interpreter. Configuring my virtualenv to use the python 3.4.1 interpreter proved to be the solution as the python interpreter was then able to find the required libraries in it's path.

Resources